Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 6, 2014 at 9:50 PM, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, 6 Feb 2014 21:45:36 +0100 Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> 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.

Yes, of course. CET sleep time...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-next" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux