From: Paul Jackson <pj@sgi.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: aebr@win.tue.nl, vojtech@suse.cz, torvalds@osdl.org,
akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix NR_KEYS off-by-one error
Date: Wed, 28 Jul 2004 23:15:48 -0700 [thread overview]
Message-ID: <20040728231548.4edebd5b.pj@sgi.com> (raw)
In-Reply-To: <87llh3ihcn.fsf@ibmpc.myhome.or.jp>
Thank-you for considering my comments.
OGAWA wrote:
> because it limits the range when struct kbentry
> was changed. (I think this change is likely)
I'm not sure I understand this comment -- but I am guessing that
you mean that:
> + unsigned char s, i;
> + unsigned short v;
would limit s, i, and v if struct kbentry was changed to have
larger types (short or int, say) for these.
Good point.
Would it work to use larger types for local variables s, i, and v now,
in order to avoid the ugly macro, as in:
unsigned int s, i, v;
However, if I have guessed incorrectly, then this idea may make no
sense. If so, sorry about that.
> key_map is pointer, so ARRAY_SIZE() can't use.
Yes - good point.
> Anyhow these will be warned by gcc.
If larger types, as I wrote above, were used for s, i, and v,
then does gcc still warn?
> Although overhead is insignificance, I'd hated to add overhead of this
> test because test is not needed right now.
Code clarity matters most here. If the code had been crystal clear
to the casual reader, then the initial mistake, of removing the
range checking, probably would never have occurred in the first place,
and we human beings would have already saved more time than we can ever
hope to save by optimizing this code.
You are absolutely correct that overhead is insignificant.
But code clarity - that is very significant <smile>.
Let all the essential details be spelled out, in the simplest
most easily read, C statements that can be found to express it.
Each line of code we put in the kernel will be read by many people
doing various things. They will be more likely to have a correct
understanding of our code if it is clear and simple, with a minimum
of surprises.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
next prev parent reply other threads:[~2004-07-29 6:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-16 16:35 [PATCH] Fix NR_KEYS off-by-one error OGAWA Hirofumi
2004-07-16 16:44 ` Vojtech Pavlik
2004-07-16 17:18 ` OGAWA Hirofumi
2004-07-16 20:15 ` Andries Brouwer
2004-07-17 6:23 ` OGAWA Hirofumi
2004-07-26 22:43 ` Andrew Morton
2004-07-27 13:46 ` Vojtech Pavlik
2004-07-27 16:37 ` OGAWA Hirofumi
2004-07-27 17:54 ` Vojtech Pavlik
2004-07-27 18:35 ` OGAWA Hirofumi
2004-07-28 11:51 ` Andries Brouwer
2004-07-28 16:46 ` OGAWA Hirofumi
2004-07-28 20:42 ` Paul Jackson
2004-07-29 4:10 ` OGAWA Hirofumi
2004-07-29 6:15 ` Paul Jackson [this message]
2004-07-29 9:24 ` OGAWA Hirofumi
2004-07-29 9:49 ` Paul Jackson
2004-07-29 23:24 ` Andrew Morton
2004-07-29 23:51 ` Paul Jackson
2004-07-30 1:25 ` OGAWA Hirofumi
2004-07-30 7:27 ` Paul Jackson
2004-07-30 8:07 ` Vojtech Pavlik
2004-07-30 8:41 ` Andries Brouwer
2004-07-30 8:51 ` Vojtech Pavlik
2004-07-30 9:03 ` Vojtech Pavlik
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=20040728231548.4edebd5b.pj@sgi.com \
--to=pj@sgi.com \
--cc=aebr@win.tue.nl \
--cc=akpm@osdl.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=vojtech@suse.cz \
/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