public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Andries Brouwer <aebr@win.tue.nl>
Cc: viro@parcelfarce.linux.theplanet.co.uk,
	Stewart Smith <stewartsmith@mac.com>,
	linux-kernel@vger.kernel.org, trivial@rustcorp.com.au
Subject: Re: buffer_head.b_bsize type
Date: Fri, 30 May 2003 19:20:30 -0700	[thread overview]
Message-ID: <20030531022030.GU15692@holomorphy.com> (raw)
In-Reply-To: <20030530162434.A2700@pclin040.win.tue.nl>

On Fri, May 30, 2003 at 04:24:34PM +0200, Andries Brouwer wrote:
> 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.

I don't see what the big deal is. Arithmetic in Z/2**32Z or whatever
doesn't really define a comparison, we just artificially impose our
favorite residues and have to check various preconditions for the
results of comparisons to make sense (which obviously aren't checked
in your example of garbage produced by a comparison).

You are right in that some attempt at an audit should be done if it
were to be changed, of course. I generally think of it as easy, and
assume it will be done.

-- wli

  parent reply	other threads:[~2003-05-31  2:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-29 10:29 buffer_head.b_bsize type Stewart Smith
2003-05-29 10:35 ` William Lee Irwin III
2003-05-29 11:15   ` viro
2003-05-29 11:28     ` William Lee Irwin III
2003-05-30 14:24       ` Andries Brouwer
2003-05-30 14:43         ` Andries Brouwer
2003-05-31  2:20         ` William Lee Irwin III [this message]
2003-05-29 14:19     ` Stewart Smith

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=20030531022030.GU15692@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=aebr@win.tue.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stewartsmith@mac.com \
    --cc=trivial@rustcorp.com.au \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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