linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 1/2] bcache: Use %zi to format size_t
@ 2014-01-15  9:06 Geert Uytterhoeven
  2014-01-15  9:06 ` [PATCH -next 2/2] bcache: Use max_t() when comparing different types Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-01-15  9:06 UTC (permalink / raw)
  To: Kent Overstreet, Neil Brown
  Cc: linux-bcache, linux-kernel, linux-next, Geert Uytterhoeven

drivers/md/bcache/extents.c: In function ‘btree_ptr_bad_expensive’:
drivers/md/bcache/extents.c:196: warning: format ‘%li’ expects type ‘long int’, but argument 4 has type ‘size_t’

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/md/bcache/extents.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index c3ead586dc27..416d1a3e028e 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -194,7 +194,7 @@ err:
 	mutex_unlock(&b->c->bucket_lock);
 	bch_extent_to_text(buf, sizeof(buf), k);
 	btree_bug(b,
-"inconsistent btree pointer %s: bucket %li pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i",
+"inconsistent btree pointer %s: bucket %zi pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i",
 		  buf, PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin),
 		  g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen);
 	return true;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-01-15  9:06 [PATCH -next 1/2] bcache: Use %zi to format size_t Geert Uytterhoeven
@ 2014-01-15  9:06 ` Geert Uytterhoeven
  2014-01-15 11:06   ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-01-15  9:06 UTC (permalink / raw)
  To: Kent Overstreet, Neil Brown
  Cc: linux-bcache, linux-kernel, linux-next, Geert Uytterhoeven

drivers/md/bcache/btree.c: In function ‘insert_u64s_remaining’:
drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/md/bcache/btree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 98cc0a810a36..c2ebc850d9a9 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
 	if (b->keys.ops->is_extents)
 		ret -= KEY_MAX_U64S;
 
-	return max(ret, 0L);
+	return max_t(ssize_t, ret, 0L);
 }
 
 static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2014-01-15 11:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kent Overstreet, Neil Brown, linux-bcache, linux-kernel, linux-next

On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
> drivers/md/bcache/btree.c: In function ‘insert_u64s_remaining’:
> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
[]
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
[]
> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
>  	if (b->keys.ops->is_extents)
>  		ret -= KEY_MAX_U64S;
>  
> -	return max(ret, 0L);
> +	return max_t(ssize_t, ret, 0L);

why not
	return max(ret, 0);

I think it odd that:

drivers/md/bcache/bset.h:static inline size_t bch_btree_keys_u64s_remaining(struct btree_keys *b)

and:

static size_t insert_u64s_remaining(struct btree *b)
{
	ssize_t ret = bch_btree_keys_u64s_remaining(&b->keys);

	/*
	 * Might land in the middle of an existing extent and have to split it
	 */
	if (b->keys.ops->is_extents)
		ret -= KEY_MAX_U64S;

	return max(ret, 0L);
}

so the only use of that size_t inline is cast to ssize_t

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-01-15 11:06   ` Joe Perches
@ 2014-02-03 13:47     ` Geert Uytterhoeven
  2014-02-06  9:00       ` Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-02-03 13:47 UTC (permalink / raw)
  To: Joe Perches
  Cc: Kent Overstreet, Neil Brown, linux-bcache, linux-kernel, Linux-Next

On Wed, Jan 15, 2014 at 12:06 PM, Joe Perches <joe@perches.com> wrote:
> On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
>> drivers/md/bcache/btree.c: In function ‘insert_u64s_remaining’:
>> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
> []
>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> []
>> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
>>       if (b->keys.ops->is_extents)
>>               ret -= KEY_MAX_U64S;
>>
>> -     return max(ret, 0L);
>> +     return max_t(ssize_t, ret, 0L);
>
> why not
>         return max(ret, 0);

Indeed, that also works, on both 32-bit and 64-bit.
Will resend, now all the issues moved from -next to Linus' tree.

> I think it odd that:
>
> drivers/md/bcache/bset.h:static inline size_t bch_btree_keys_u64s_remaining(struct btree_keys *b)
>
> and:
>
> static size_t insert_u64s_remaining(struct btree *b)
> {
>         ssize_t ret = bch_btree_keys_u64s_remaining(&b->keys);
>
>         /*
>          * Might land in the middle of an existing extent and have to split it
>          */
>         if (b->keys.ops->is_extents)
>                 ret -= KEY_MAX_U64S;
>
>         return max(ret, 0L);
> }
>
> so the only use of that size_t inline is cast to ssize_t

If the value returned by bch_btree_keys_u64s_remaining() is smaller
than KEY_MAX_U64S, it must stay negative after the subtraction,
instead of wrapping around to a big positive number. That's why ret is
ssize_t and not size_t.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-03 13:47     ` Geert Uytterhoeven
@ 2014-02-06  9:00       ` Geert Uytterhoeven
  2014-02-06  9:06         ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-02-06  9:00 UTC (permalink / raw)
  To: Joe Perches, Andrew Morton
  Cc: Kent Overstreet, Neil Brown, linux-bcache, linux-kernel, Linux-Next

On Mon, Feb 3, 2014 at 2:47 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, Jan 15, 2014 at 12:06 PM, Joe Perches <joe@perches.com> wrote:
>> On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
>>> drivers/md/bcache/btree.c: In function ‘insert_u64s_remaining’:
>>> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
>> []
>>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
>> []
>>> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
>>>       if (b->keys.ops->is_extents)
>>>               ret -= KEY_MAX_U64S;
>>>
>>> -     return max(ret, 0L);
>>> +     return max_t(ssize_t, ret, 0L);
>>
>> why not
>>         return max(ret, 0);
>
> Indeed, that also works, on both 32-bit and 64-bit.
> Will resend, now all the issues moved from -next to Linus' tree.

However, sparse doesn't like it, so we'll have to go for v1?

From kbuild test robot fengguang.wu@intel.com:

>> drivers/md/bcache/btree.c:1816:16: sparse: incompatible types in comparison expression (different type sizes)
   In file included from arch/x86/include/asm/percpu.h:44:0,
                    from arch/x86/include/asm/preempt.h:5,
                    from include/linux/preempt.h:18,
                    from include/linux/spinlock.h:50,
                    from include/linux/wait.h:8,
                    from include/linux/fs.h:6,
                    from include/linux/highmem.h:4,
                    from include/linux/bio.h:23,
                    from drivers/md/bcache/bcache.h:181,
                    from drivers/md/bcache/btree.c:23:
   drivers/md/bcache/btree.c: In function 'insert_u64s_remaining':
   include/linux/kernel.h:718:17: warning: comparison of distinct
pointer types lacks a cast [enabled by default]
     (void) (&_max1 == &_max2);  \
                    ^
   drivers/md/bcache/btree.c:1816:9: note: in expansion of macro 'max'
     return max(ret, 0);
            ^

vim +1816 drivers/md/bcache/btree.c

  1800                                                status);
  1801                  return true;
  1802          } else
  1803                  return false;
  1804  }
  1805
  1806  static size_t insert_u64s_remaining(struct btree *b)
  1807  {
  1808          ssize_t ret = bch_btree_keys_u64s_remaining(&b->keys);
  1809
  1810          /*
  1811           * Might land in the middle of an existing extent and
have to split it
  1812           */
  1813          if (b->keys.ops->is_extents)
  1814                  ret -= KEY_MAX_U64S;
  1815
> 1816          return max(ret, 0);
  1817  }
  1818
  1819  static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op,
  1820                                    struct keylist *insert_keys,
  1821                                    struct bkey *replace_key)
  1822  {
  1823          bool ret = false;
  1824          int oldsize = bch_count_data(&b->keys);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-06  9:00       ` Geert Uytterhoeven
@ 2014-02-06  9:06         ` Joe Perches
  2014-02-06 20:38           ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2014-02-06  9:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Andrew Morton, Kent Overstreet, Neil Brown, linux-bcache,
	linux-kernel, Linux-Next

On Thu, 2014-02-06 at 10:00 +0100, Geert Uytterhoeven wrote:
> On Mon, Feb 3, 2014 at 2:47 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Wed, Jan 15, 2014 at 12:06 PM, Joe Perches <joe@perches.com> wrote:
> >> On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
> >>> drivers/md/bcache/btree.c: In function ‘insert_u64s_remaining’:
> >>> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
> >> []
> >>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> >> []
> >>> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
> >>>       if (b->keys.ops->is_extents)
> >>>               ret -= KEY_MAX_U64S;
> >>>
> >>> -     return max(ret, 0L);
> >>> +     return max_t(ssize_t, ret, 0L);
> >>
> >> why not
> >>         return max(ret, 0);
> >
> > Indeed, that also works, on both 32-bit and 64-bit.
> > Will resend, now all the issues moved from -next to Linus' tree.
> 
> However, sparse doesn't like it, so we'll have to go for v1?

Seems so.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-06  9:06         ` Joe Perches
@ 2014-02-06 20:38           ` Andrew Morton
  2014-02-06 20:45             ` Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2014-02-06 20:38 UTC (permalink / raw)
  To: Joe Perches
  Cc: Geert Uytterhoeven, Kent Overstreet, Neil Brown, linux-bcache,
	linux-kernel, Linux-Next

On Thu, 06 Feb 2014 01:06:47 -0800 Joe Perches <joe@perches.com> wrote:

> On Thu, 2014-02-06 at 10:00 +0100, Geert Uytterhoeven wrote:
> > On Mon, Feb 3, 2014 at 2:47 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > On Wed, Jan 15, 2014 at 12:06 PM, Joe Perches <joe@perches.com> wrote:
> > >> On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
> > >>> drivers/md/bcache/btree.c: In function ___insert_u64s_remaining___:
> > >>> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
> > >> []
> > >>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> > >> []
> > >>> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
> > >>>       if (b->keys.ops->is_extents)
> > >>>               ret -= KEY_MAX_U64S;
> > >>>
> > >>> -     return max(ret, 0L);
> > >>> +     return max_t(ssize_t, ret, 0L);
> > >>
> > >> why not
> > >>         return max(ret, 0);
> > >
> > > Indeed, that also works, on both 32-bit and 64-bit.
> > > Will resend, now all the issues moved from -next to Linus' tree.
> > 
> > However, sparse doesn't like it, so we'll have to go for v1?
> 
> Seems so.

Kent, was there any secret reason why insert_u64s_remaining():ret has
type ssize_t?  The function returns size_t and
bch_btree_keys_u64s_remaining() returns size_t so I think I'll do the
obvious:


--- 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;
 
-	return max(ret, 0);
+	return max_t(size_t, ret, 0);
 }
 
 static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op,
_

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-06 20:38           ` Andrew Morton
@ 2014-02-06 20:45             ` Geert Uytterhoeven
  2014-02-06 20:50               ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-02-06 20:45 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joe Perches, Kent Overstreet, Neil Brown, linux-bcache,
	linux-kernel, Linux-Next

On Thu, Feb 6, 2014 at 9:38 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>> On Thu, 2014-02-06 at 10:00 +0100, Geert Uytterhoeven wrote:
>> > On Mon, Feb 3, 2014 at 2:47 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> > > On Wed, Jan 15, 2014 at 12:06 PM, Joe Perches <joe@perches.com> wrote:
>> > >> On Wed, 2014-01-15 at 10:06 +0100, Geert Uytterhoeven wrote:
>> > >>> drivers/md/bcache/btree.c: In function ___insert_u64s_remaining___:
>> > >>> drivers/md/bcache/btree.c:1816: warning: comparison of distinct pointer types lacks a cast
>> > >> []
>> > >>> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
>> > >> []
>> > >>> @@ -1813,7 +1813,7 @@ static size_t insert_u64s_remaining(struct btree *b)
>> > >>>       if (b->keys.ops->is_extents)
>> > >>>               ret -= KEY_MAX_U64S;
>> > >>>
>> > >>> -     return max(ret, 0L);
>> > >>> +     return max_t(ssize_t, ret, 0L);
>> > >>
>> > >> why not
>> > >>         return max(ret, 0);
>> > >
>> > > Indeed, that also works, on both 32-bit and 64-bit.
>> > > Will resend, now all the issues moved from -next to Linus' tree.
>> >
>> > However, sparse doesn't like it, so we'll have to go for v1?
>>
>> Seems so.
>
> Kent, was there any secret reason why insert_u64s_remaining():ret has
> type ssize_t?  The function returns size_t and
> bch_btree_keys_u64s_remaining() returns size_t so I think I'll do the
> obvious:
>
>
> --- 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.

>
> -       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).

>  }
>
>  static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op,

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-06 20:45             ` Geert Uytterhoeven
@ 2014-02-06 20:50               ` Andrew Morton
  2014-02-06 20:53                 ` Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2014-02-06 20:50 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Perches, Kent Overstreet, Neil Brown, linux-bcache,
	linux-kernel, Linux-Next

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -next 2/2] bcache: Use max_t() when comparing different types
  2014-02-06 20:50               ` Andrew Morton
@ 2014-02-06 20:53                 ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2014-02-06 20:53 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joe Perches, Kent Overstreet, Neil Brown, linux-bcache,
	linux-kernel, Linux-Next

On Thu, Feb 6, 2014 at 9:50 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> 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.

Yes, of course. CET sleep time...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-06 20:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2014-02-06 20:53                 ` Geert Uytterhoeven

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).