Re: [PATCH] random.c bugfix

Robert Love (rml@tech9.net)
27 Oct 2001 02:35:55 -0400


On Sat, 2001-10-27 at 02:21, Andreas Dilger wrote:
> OK, my bad. At least the random variable-name cleanups let you SEE where
> we are supposed to be using word sizes and byte sizes. Even you were
> confused about it ;-)

I went over your original patch good; I am surprised I missed this. :/
Nonetheless, only with the new cleanups could anyone spot this.

> Well, this is a matter of taste. With my code, it is correct regardless
> of how tmp is declared, while with your code you assume tmp is TMP_BUF_SIZE
> words, and that it is declared with a 4-byte type. Both ways are resolved
> at compile time, so using "sizeof(tmp)/4" or "sizeof(tmp)*8" doesn't add
> any run-time overhead.

I think I prefer your sizeof() method, if for nothing else but that we
can keep it consistent -- we can always take the sizeof a variable and
not everything has its size in a define.

Furthermore, sizeof(tmp) certainly means "size of the variable temp"
while TMP_BUF_SIZE could be the size of anything related to tmp -- the
buffer it points to (if it were a pointer), a buffer in it (if it were a
struct), etc. Since it all compiles to the same, it is not a huge
issue. Just my two bits...

> I don't have a strong opinion either way, if Linus and/or Alan have a
> preference to do it one way or the other.

...but I'm not Alan or Linus ;)

Robert Love

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/