linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Joe Perches <joe@perches.com>,
	Kent Overstreet <kmo@daterainc.com>, Neil Brown <neilb@suse.de>,
	linux-bcache@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux-Next <linux-next@vger.kernel.org>
Subject: Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
Date: Thu, 6 Feb 2014 12:50:58 -0800	[thread overview]
Message-ID: <20140206125058.8b5d884cca468b9850d5b538@linux-foundation.org> (raw)
In-Reply-To: <CAMuHMdVJ8N7UHWz6aMdurwpKwafb_V0AS7MyUQWftiH9C-8b5A@mail.gmail.com>

On Thu, 6 Feb 2014 21:45:36 +0100 Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> > --- a/drivers/md/bcache/btree.c~bcache-drop-l-suffix-when-comparing-ssize_t-with-0-fix
> > +++ a/drivers/md/bcache/btree.c
> > @@ -1805,7 +1805,7 @@ static bool btree_insert_key(struct btre
> >
> >  static size_t insert_u64s_remaining(struct btree *b)
> >  {
> > -       ssize_t ret = bch_btree_keys_u64s_remaining(&b->keys);
> > +       size_t ret = bch_btree_keys_u64s_remaining(&b->keys);
> >
> >         /*
> >          * Might land in the middle of an existing extent and have to split it
> > @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(stru
> >         if (b->keys.ops->is_extents)
> >                 ret -= KEY_MAX_U64S;
> 
> I think the reason is the line above: with size_t, ret may become a big
> positive number when the subtraction wraps below zero.

Well, I assumed that case would be a bug - otherwise the programmer
would have commented such a subtlety.  Wouldn't he?

> >
> > -       return max(ret, 0);
> > +       return max_t(size_t, ret, 0);
> 
> That part is OK, cfr. my v1 (which I had planned to send out as v3 again).

It needs to be ssize_t.

  reply	other threads:[~2014-02-06 20:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15  9:06 [PATCH -next 1/2] bcache: Use %zi to format size_t Geert Uytterhoeven
2014-01-15  9:06 ` [PATCH -next 2/2] bcache: Use max_t() when comparing different types Geert Uytterhoeven
2014-01-15 11:06   ` Joe Perches
2014-02-03 13:47     ` Geert Uytterhoeven
2014-02-06  9:00       ` Geert Uytterhoeven
2014-02-06  9:06         ` Joe Perches
2014-02-06 20:38           ` Andrew Morton
2014-02-06 20:45             ` Geert Uytterhoeven
2014-02-06 20:50               ` Andrew Morton [this message]
2014-02-06 20:53                 ` Geert Uytterhoeven

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=20140206125058.8b5d884cca468b9850d5b538@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=geert@linux-m68k.org \
    --cc=joe@perches.com \
    --cc=kmo@daterainc.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=neilb@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).