public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Octal vs. Hex war o' death
@ 2000-11-29 23:27 Ian S. Nelson
  2000-11-30  0:17 ` Jeff Epler
  2000-11-30  0:43 ` Octal vs. Hex war o' death Alexander Viro
  0 siblings, 2 replies; 8+ messages in thread
From: Ian S. Nelson @ 2000-11-29 23:27 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

[-- 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);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-11-30 17:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-29 23:27 Octal vs. Hex war o' death Ian S. Nelson
2000-11-30  0:17 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox