lkml.org 
[lkml]   [2003]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: buffer_head.b_bsize type
On Thu, May 29, 2003 at 04:28:41AM -0700, William Lee Irwin III wrote:

> The thought behind my comment was that it didn't make sense to allow
> the representation to go negative. There of course shouldn't ever be
> any need to allow >= 2GB b_size to be representable.

Not about this particular case, but as a general remark:
Use of unsigned is dangerous - use of int is far preferable,
everywhere that is possible.

With ints the test a+b > c is equivalent to the test a > c-b.
Intuition works.

As soon as there is some unsigned in an expression comparisons
get counterintuitive because -1 is very large.
Thus, 1+sizeof(int) > 3 is true, but 1 > 3-sizeof(int) is false.

It has happened several times that kernel code was broken because
some variable (that always was nonnegative) was made unsigned.

Andries

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:0.060 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site