From: Bart Van Assche <bvanassche@acm.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jason Gunthorpe <jgg@mellanox.com>
Cc: Kees Cook <keescook@chromium.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Leon Romanovsky <leonro@mellanox.com>
Subject: Re: [PATCH] Avoid that check_shl_overflow() triggers a compiler warning when building with W=1
Date: Thu, 07 Mar 2019 16:08:23 -0800 [thread overview]
Message-ID: <1552003703.45180.17.camel@acm.org> (raw)
In-Reply-To: <2c122567-d14b-7867-9230-67f570c13d15@rasmusvillemoes.dk>
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.
next prev parent reply other threads:[~2019-03-08 0:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 1:01 [PATCH] Avoid that check_shl_overflow() triggers a compiler warning when building with W=1 Bart Van Assche
2019-03-07 1:24 ` Jason Gunthorpe
2019-03-07 2:14 ` Bart Van Assche
2019-03-07 7:18 ` Rasmus Villemoes
2019-03-08 0:08 ` Bart Van Assche [this message]
2019-03-08 7:01 ` Leon Romanovsky
2019-03-08 8:09 ` Rasmus Villemoes
2019-03-08 15:53 ` Leon Romanovsky
2019-03-08 21:32 ` Rasmus Villemoes
2019-03-08 7:58 ` Rasmus Villemoes
2019-03-08 12:41 ` Jason Gunthorpe
2019-03-07 7:24 ` Leon Romanovsky
2019-03-07 14:53 ` Bart Van Assche
2019-03-07 15:40 ` Leon Romanovsky
2019-03-07 16:52 ` Kees Cook
2019-03-07 17:02 ` Leon Romanovsky
2019-03-07 17:12 ` Kees Cook
2019-03-07 17:36 ` Leon Romanovsky
2019-03-07 20:28 ` Rasmus Villemoes
2019-03-08 7:03 ` Leon Romanovsky
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=1552003703.45180.17.camel@acm.org \
--to=bvanassche@acm.org \
--cc=jgg@mellanox.com \
--cc=keescook@chromium.org \
--cc=leonro@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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