All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Jason Gunthorpe <jgg@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Bart Van Assche <Bart.VanAssche@wdc.com>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma <linux-rdma@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper
Date: Wed, 1 Aug 2018 08:38:01 -0700	[thread overview]
Message-ID: <CAGXu5j+=gBk=6Pva36HFj1L=Bz2O1+kzcUwUEu8eme_A4F5ktg@mail.gmail.com> (raw)
In-Reply-To: <20180801080724.2vgzagooda56aypw@mwanda>

On Wed, Aug 1, 2018 at 1:07 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Wed, Aug 01, 2018 at 10:57:44AM +0300, Dan Carpenter wrote:
>> The idea is nice, but I don't like the API.  The "_overflow" feels too
>> specific because maybe we could check for other things in the future.
>> Normally boolean macros should say they are boolean in the name and I
>> would prefer if it returned zero on failure.
>>
>>       if (!checked_shift(dest, mask, shift)) {
>>       if (!shift_ok(dest, mask, shift)) {
>>       if (!safe_shift(dest, mask, shift)) {
>
> Huh...  It turns out I put the argument order different as well.
>
> If we wanted to keep it returning 1 on failure then some other names
> are:
>
>         if (shift_failed(dest, mask, shift)) {
>         if (shift_error(dest, mask, shift)) {
>         if (shift_overflow(dest, mask, shift)) {

This is following the existing check_{add,mul}_overflow() helpers,
which are based on the gcc helpers. I'd like to keep things
consistent.

-Kees

-- 
Kees Cook
Pixel Security

  reply	other threads:[~2018-08-01 15:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01  0:00 [PATCH v2 0/3] overflow.h: Add arithmetic shift helper Kees Cook
2018-08-01  0:00 ` [PATCH v2 1/3] " Kees Cook
2018-08-01  1:59   ` Randy Dunlap
2018-08-01  2:15   ` Jason Gunthorpe
2018-08-01  4:22     ` Kees Cook
2018-08-01  7:57   ` Dan Carpenter
2018-08-01  8:07     ` Dan Carpenter
2018-08-01 15:38       ` Kees Cook [this message]
2018-08-01 15:48       ` Jason Gunthorpe
2018-08-01  0:00 ` [PATCH v2 2/3] test_overflow: Add shift overflow tests Kees Cook
2018-08-01  2:13   ` Jason Gunthorpe
2018-08-01  5:51     ` Kees Cook
2018-08-01  0:00 ` [PATCH v2 3/3] RDMA/mlx5: Fix shift overflow in mlx5_ib_create_wq Kees Cook

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='CAGXu5j+=gBk=6Pva36HFj1L=Bz2O1+kzcUwUEu8eme_A4F5ktg@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=Bart.VanAssche@wdc.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.