lkml.org 
[lkml]   [2019]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Avoid that check_shl_overflow() triggers a compiler warning when building with W=1
From
Date
On Thu, 2019-03-07 at 08:18 +0100, Rasmus Villemoes wrote:
> On 07/03/2019 03.14, Bart Van Assche wrote:
> > On 3/6/19 5:24 PM, Jason Gunthorpe wrote:
> > > >
> > > > diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> > > > index 40b48e2133cb..8afe0c0ada6f 100644
> > > > +++ b/include/linux/overflow.h
> > > > @@ -202,6 +202,24 @@
> > > > #endif /* COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW */
> > > > +/*
> > > > + * Evaluate a >= 0 without triggering a compiler warning if the type
> > > > of a
> > > > + * is an unsigned type.
> > > > + */
> > > > +#define is_positive(a) ({ \
>
> is_non_negative, please! positive means > 0. And perhaps it's better to
> move these utility macros closer to the top of the file, together with
> the other type/range helpers.

Hi Rasmus,

Thank you for the feedback. But according to what I found online opinions
about whether or not zero is a positive number seem to vary. From
https://en.wikipedia.org/wiki/Sign_(mathematics):

Terminology for signs

When 0 is said to be neither positive nor negative, the following phrases
may be used to refer to the sign of a number:
* A number is positive if it is greater than zero.
* A number is negative if it is less than zero.
* A number is non-negative if it is greater than or equal to zero.
* A number is non-positive if it is less than or equal to zero.

When 0 is said to be both positive and negative, modified phrases are used
to refer to the sign of a number:
* A number is strictly positive if it is greater than zero.
* A number is strictly negative if it is less than zero.
* A number is positive if it is greater than or equal to zero.
* A number is negative if it is less than or equal to zero.

Bart.

\
 
 \ /
  Last update: 2019-03-08 01:09    [W:0.101 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site