linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ian S. Nelson" <ian.nelson@echostar.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Octal vs. Hex war o' death
Date: Wed, 29 Nov 2000 16:27:04 -0700	[thread overview]
Message-ID: <3A2590C8.34459BF9@echostar.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1698 bytes --]

I'm sure this is a religious issue... but I'm going to suggest it
anyways because I spent a few minutes on it.

So I was hacking away trying to get my embedded box to run the correct
stuff after booting up and I ran into an octal speed bump.  You see, all
throughout rd.c there are these hex constants, like there should be.  In
fact most constants in the kernel are in the 2 friendliest number
formats known, hex and dec.

in rd.c there is an:
memset(buf, 0xe5, size);

a:
 printk("%c\b", rotator[rotate & 0x3]);

and a:
#define WSIZE 0x8000

and several others, all in hex.

Then I ran into this black sheep:
 if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {


I vote that we make this consistent and fix it.  So I've included a
handy patch to correct this "bug."  My rationale is that a) most
constants are in hex or dec already,  b) my editor doesn't sport an
octal mode but it has a really handy hex mode that let's me do things
like load up an initrd and check to see that the first 2 bytes are set
correctly,  c) octals were invented for UNIX file permissions and not
programming, putting an extra "0" in there just doesn't make sense and
shouldn't change the meaning of the following digits, "0x" on the other
hand clearly denotes that you are not looking at a base 10 number.  In
math they teach you that you can arbitrarily add zeros to the front of a
number and not change it's meaning, such as the military frequently does
with time ("0700 hours.." which translates to "7:00" and not  "4:48")
and math goes together hand in hand with programming.  lastly, d) octal
numbers just don't have a good feeling to them, it's like your stuck at
half-duplex or something..



Ian


[-- Attachment #2: minutia.patch --]
[-- Type: text/plain, Size: 502 bytes --]

diff -urP virgin-linux/drivers/block/rd.c linux/drivers/block/rd.c
--- virgin-linux/drivers/block/rd.c	Fri Nov 17 17:46:55 2000
+++ linux/drivers/block/rd.c	Wed Nov 29 15:45:33 2000
@@ -497,7 +497,7 @@
 	/*
 	 * If it matches the gzip magic numbers, return -1
 	 */
-	if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {
+	if (buf[0] == 0x1f && ((buf[1] == 0x8b) || (buf[1] == 0x9e))) {
 		printk(KERN_NOTICE
 		       "RAMDISK: Compressed image found at block %d\n",
 		       start_block);

             reply	other threads:[~2000-11-29 23:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-29 23:27 Ian S. Nelson [this message]
2000-11-30  0:17 ` Octal vs. Hex war o' death Jeff Epler
2000-11-30  0:22   ` H. Peter Anvin
2000-11-30  0:39     ` PROBLEM: do_try_free_pages failed for python Bob Tanner
2000-11-30 16:06       ` Rik van Riel
2000-11-30 16:29         ` Andrea Arcangeli
2000-11-30  0:43 ` Octal vs. Hex war o' death Alexander Viro
2000-11-30  4:07   ` Igmar Palsenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A2590C8.34459BF9@echostar.com \
    --to=ian.nelson@echostar.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).