From: Martin Dalecki <dalecki@evision-ventures.com>
To: Oliver Xymoron <oxymoron@waste.org>
Cc: Linus Torvalds <torvalds@transmeta.com>,
Pavel Machek <pavel@ucw.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.5.10 IDE 42
Date: Fri, 26 Apr 2002 23:34:17 +0200 [thread overview]
Message-ID: <3CC9C7D9.5000000@evision-ventures.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0204261454440.30456-100000@waste.org>
Uz.ytkownik Oliver Xymoron napisa?:
> On Fri, 26 Apr 2002, Linus Torvalds wrote:
>
>
>>
>>On Fri, 26 Apr 2002, Pavel Machek wrote:
>>
>>>>+ if (stat & READY_STAT)
>>>>+ printk("DriveReady ");
>>>>+ if (stat & WRERR_STAT)
>>>>+ printk("DeviceFault ");
>>>>+ if (stat & SEEK_STAT)
>>>>+ printk("SeekComplete ");
>>>>+ if (stat & DRQ_STAT)
>>>>+ printk("DataRequest ");
>>>>+ if (stat & ECC_STAT)
>>>>+ printk("CorrectedError ");
>>>>+ if (stat & INDEX_STAT)
>>>>+ printk("Index ");
>>>>+ if (stat & ERR_STAT)
>>>>+ printk("Error ");
>>>
>>>I believe this is actually making it *less* readable.
>>
>>Somewhat agreed. Also, the above is just not the right way to do
>>printouts.
>>
>>I'd suggest rewriting the whole big mess as something like
>>
>> #define STAT_STR(x,s) \
>> ((stat & x ##_STAT) ? s " " : "")
>>
>> ...
>>
>> printf("IDE: %s%s%s%s%s%s..\n"
>> STAT_STR(READY, "DriveReady"),
>> STAT_STR(WERR, "DeviceFault"),
>> ...
>
>
> I'd go even further and suggest that pulling the mapping from a mask or
> key to string out into a table and looping through it is preferable for
> this sort of thing. You win later if you decide you need the same mapping
> elsewhere or if you want to format your messages differently, add bits to
> it, etc. Tables are generally easier to inspect for errors than code,
> although Linus' version is very nearly a table.
>
> Maintaining tables as code is a pain and is generally only a win for
> small or sparse state machines.
Yes I will use an ffz() based loop to lookup a table.
next prev parent reply other threads:[~2002-04-26 22:36 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-23 8:18 2.5.9 -- OOPS in IDE code (symbolic dump and boot log included) Miles Lane
2002-04-23 8:00 ` Martin Dalecki
2002-04-23 9:18 ` Jens Axboe
2002-04-23 8:43 ` Martin Dalecki
2002-04-23 9:54 ` Jens Axboe
2002-04-23 17:39 ` Miles Lane
2002-04-23 17:54 ` Miles Lane
2002-04-24 8:06 ` Martin Dalecki
2002-04-24 9:11 ` Jens Axboe
2002-04-24 8:20 ` Martin Dalecki
2002-04-25 11:07 ` Martin Dalecki
2002-04-25 17:25 ` Jens Axboe
2002-04-25 17:34 ` Jens Axboe
2002-04-25 21:02 ` Linus Torvalds
2002-04-26 7:33 ` [PATCH] 2.5.10 UTS_VERSION Martin Dalecki
2002-04-26 9:52 ` Keith Owens
2002-04-26 8:58 ` Martin Dalecki
2002-04-26 7:41 ` [PATCH] 2.5.10 IDE 42 Martin Dalecki
2002-04-26 16:09 ` Pavel Machek
2002-04-26 17:31 ` Dave Jones
2002-04-26 17:37 ` Linus Torvalds
2002-04-26 20:05 ` Oliver Xymoron
2002-04-26 21:34 ` Martin Dalecki [this message]
2002-04-26 22:25 ` Martin Dalecki
2002-04-26 21:32 ` Martin Dalecki
2002-04-26 23:21 ` Rene Rebe
2002-04-26 21:42 ` Martin Dalecki
2002-04-26 16:10 ` Sebastian Droege
2002-04-26 21:28 ` Martin Dalecki
2002-04-26 22:44 ` Padraig Brady
2002-04-28 9:18 ` Kai Henningsen
2002-05-05 15:54 ` [PATCH] 2.5.13 IDE 52 Martin Dalecki
2002-05-05 17:09 ` Jens Axboe
2002-05-05 16:16 ` Martin Dalecki
2002-05-05 15:55 ` [PATCH] 2.5.13 IDE 53 Martin Dalecki
2002-05-06 9:53 ` Russell King
2002-05-06 8:55 ` Martin Dalecki
2002-05-06 23:48 ` jw schultz
2002-05-05 15:56 ` [PATCH 2.5.13 IDE 54 Martin Dalecki
2002-05-07 12:52 ` Paul Mackerras
2002-05-07 12:06 ` Martin Dalecki
2002-05-07 14:40 ` benh
2002-05-07 13:40 ` Martin Dalecki
2002-05-07 15:18 ` benh
2002-05-07 14:07 ` Alan Cox
2002-05-07 13:24 ` Martin Dalecki
2002-04-24 9:29 ` 2.5.9 -- OOPS in IDE code (symbolic dump and boot log included) Luigi Genoni
2002-04-23 18:23 ` Melchior FRANZ
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=3CC9C7D9.5000000@evision-ventures.com \
--to=dalecki@evision-ventures.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oxymoron@waste.org \
--cc=pavel@ucw.cz \
--cc=torvalds@transmeta.com \
/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