cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: cocci <cocci@systeme.lip6.fr>
Subject: [Cocci] linux: bad logic in repetitive tests
Date: Mon, 30 Mar 2020 17:52:21 -0700	[thread overview]
Message-ID: <f8581a548767a5d7e460816f125566fca8694aa0.camel@perches.com> (raw)

There is a block of if tests against the same variable
in include/linux/mtd/pfow.h that likely is defective

        if (prog_status & 0x3)
                ...
        else if (prog_status & 0x2)
                ...
        else (prog_status & 0x1)
                ...

If the first test is true the subsequent 2 tests aren't
possible.

Likely the first test should be something like

	if ((prog_status & 0x03) == 0x03)

Is there a way for cocci to find this style of bitwise
logic defect?



_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

             reply	other threads:[~2020-03-31  3:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  0:52 Joe Perches [this message]
2020-03-31  8:50 ` [Cocci] linux: bad logic in repetitive tests Julia Lawall
2020-03-31  9:02   ` Joe Perches
2020-03-31  9:12     ` Julia Lawall

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=f8581a548767a5d7e460816f125566fca8694aa0.camel@perches.com \
    --to=joe@perches.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@lip6.fr \
    /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;
as well as URLs for NNTP newsgroup(s).