mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [2.4.23-pre3] Possible bug in fs/buffer.c
Date: Mon, 08 Sep 2003 17:42:40 +0200	[thread overview]
Message-ID: <je3cf7uw0f.fsf@sykes.suse.de> (raw)
In-Reply-To: <200309081715.09657@bilbo.math.uni-mannheim.de> (Rolf Eike Beer's message of "Mon, 8 Sep 2003 17:15:09 +0200")

Rolf Eike Beer <eike-kernel@sf-tec.de> writes:

> This is __put_unused_buffer_head from fs/buffer.c, lines 1156 to 1171:
>
>
> static void __put_unused_buffer_head(struct buffer_head * bh)
> {
> 	if (unlikely(buffer_attached(bh)))
> 		BUG();
> 	if (nr_unused_buffer_heads >= MAX_UNUSED_BUFFERS) {
> 		kmem_cache_free(bh_cachep, bh);
> 	} else {
> 		bh->b_dev = B_FREE;
> ===>		bh->b_blocknr = -1;		<===
> 		bh->b_this_page = NULL;
>
> 		nr_unused_buffer_heads++;
> 		bh->b_next_free = unused_list;
> 		unused_list = bh;
> 	}
> }
>
> In include/linux/fs.h "struct buffer_head" is defined this way:
>
> struct buffer_head {
>         /* First cache line: */
>         struct buffer_head *b_next;     /* Hash queue list */
>         unsigned long b_blocknr;        /* block number */
> ...
>
> So this line (and line 1205, which is the same) is either ugly (and someone
> meant ~0UL or something similar) or completely bogus.

It's neither ugly, nor bogus.  The only 100% reliable way to assign the
maximum value to an unsigned integer is to use -1.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2003-09-08 15:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-08 15:15 Rolf Eike Beer
2003-09-08 15:42 ` Andreas Schwab [this message]
2003-09-08 15:58   ` Alan Cox
2003-09-08 16:04     ` Andreas Schwab
2003-09-08 22:13       ` J.A. Magallon
2003-09-09  0:53       ` Alan Cox
2003-09-09 13:39         ` Rolf Eike Beer
2003-09-08 16:12     ` Rolf Eike Beer
2003-09-09  0:52       ` Alan Cox

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=je3cf7uw0f.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=eike-kernel@sf-tec.de \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome