linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Phil Carmody <phil@dovecot.fi>
Cc: sparse@chrisli.org, linux-sparse@vger.kernel.org
Subject: Re: [PATCH 3/3] validation: dubious bitwise operations with nots
Date: Mon, 9 Jun 2014 06:36:20 -0700	[thread overview]
Message-ID: <20140609133620.GC11986@thin> (raw)
In-Reply-To: <1402315082-14102-4-git-send-email-phil@dovecot.fi>

On Mon, Jun 09, 2014 at 02:58:02PM +0300, Phil Carmody wrote:
> Add some bitwise not tests.
> 
> Signed-off-by: Phil Carmody <phil@dovecot.fi>
> ---
>  validation/dubious-bitwise-with-not.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/validation/dubious-bitwise-with-not.c b/validation/dubious-bitwise-with-not.c
> index c48bcae..1cfd5c5 100644
> --- a/validation/dubious-bitwise-with-not.c
> +++ b/validation/dubious-bitwise-with-not.c
> @@ -10,8 +10,32 @@ static unsigned int ok5  = !1 && !2;
>  static unsigned int bad5 = !1 &  !2;
>  static unsigned int ok6  = !1 || !2;
>  static unsigned int bad6 = !1 |  !2;
> +static unsigned long long ok7a  = 0x100000001ull & ~1;
> +static unsigned long long ok7b  = 0x100000001ull & ~1ull;
> +static unsigned long long bad7  = 0x100000001ull & ~1u;
> +static unsigned long long ok8a  = ~1    & 0x100000001ull;
> +static unsigned long long ok8b  = ~1ull & 0x100000001ull;
> +static unsigned long long bad8  = ~1u   & 0x100000001ull;
> +static unsigned long long ok9a  = 0x100000001ull | ~1;
> +static unsigned long long ok9b  = 0x100000001ull | ~1ull;
> +static unsigned long long bad9  = 0x100000001ull | ~1u;
> +static unsigned long long ok10a = ~1    | 0x100000001ull;
> +static unsigned long long ok10b = ~1ull | 0x100000001ull;
> +static unsigned long long bad10 = ~1u   | 0x100000001ull;
> +static unsigned long long ok11a = 0x100000001ull + ~1;
> +static unsigned long long ok11b = 0x100000001ull + ~1ull;
> +static unsigned long long bad11 = 0x100000001ull + ~1u;
> +static unsigned long long ok12a = ~1    + 0x100000001ull;
> +static unsigned long long ok12b = ~1ull + 0x100000001ull;
> +static unsigned long long bad12 = ~1u   + 0x100000001ull;
> +static unsigned long long ok13a = 0x100000001ull - ~1;
> +static unsigned long long ok13b = 0x100000001ull - ~1ull;
> +static unsigned long long bad13 = 0x100000001ull - ~1u;
> +static unsigned long long ok14a = ~1    - 0x100000001ull;
> +static unsigned long long ok14b = ~1ull - 0x100000001ull;
> +static unsigned long long bad14 = ~1u   - 0x100000001ull;
>  /*
> - * check-name: Dubious bitwise operation on !x
> + * check-name: Dubious bitwise operations with nots

For clarity, I'd suggest writing this as "with !x or ~x".

>   *
>   * check-error-start
>  dubious-bitwise-with-not.c:2:31: warning: dubious: !x & y
> @@ -20,5 +44,13 @@ dubious-bitwise-with-not.c:6:31: warning: dubious: x & !y
>  dubious-bitwise-with-not.c:8:31: warning: dubious: x | !y
>  dubious-bitwise-with-not.c:10:31: warning: dubious: !x & !y
>  dubious-bitwise-with-not.c:12:31: warning: dubious: !x | !y
> +dubious-bitwise-with-not.c:15:50: warning: dubious: x & ~y
> +dubious-bitwise-with-not.c:18:41: warning: dubious: ~x & y
> +dubious-bitwise-with-not.c:21:50: warning: dubious: x | ~y
> +dubious-bitwise-with-not.c:24:41: warning: dubious: ~x | y
> +dubious-bitwise-with-not.c:27:50: warning: dubious: x + ~y
> +dubious-bitwise-with-not.c:30:41: warning: dubious: ~x + y
> +dubious-bitwise-with-not.c:33:50: warning: dubious: x - ~y
> +dubious-bitwise-with-not.c:36:41: warning: dubious: ~x - y
>   * check-error-end
>   */
> -- 
> 2.0.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-06-09 13:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 11:57 [PATCH 0/3] catch non-sign-extended '~' brainos Phil Carmody
2014-06-09 11:58 ` [PATCH 1/3] sparse: Just use simple ints for decision variables Phil Carmody
2014-06-09 11:58   ` [PATCH 2/3] sparse: detect non-sign-extended masks created by '~' Phil Carmody
2014-06-09 11:58     ` [PATCH 3/3] validation: dubious bitwise operations with nots Phil Carmody
2014-06-09 13:36       ` Josh Triplett [this message]
2014-06-09 13:34     ` [PATCH 2/3] sparse: detect non-sign-extended masks created by '~' Josh Triplett
2014-06-09 16:05       ` Phil Carmody
2014-06-09 13:27   ` [PATCH 1/3] sparse: Just use simple ints for decision variables Josh Triplett
2014-06-10  7:54 ` [PATCHv2 0/3] catch non-sign-extended '~' brainos Phil Carmody
2014-06-10  7:54   ` [PATCHv2 1/3] sparse: Just use simple ints for decision variables Phil Carmody
2014-06-10  7:54     ` [PATCHv2 2/3] sparse: detect non-sign-extended masks created by '~' Phil Carmody
2014-06-10  7:54       ` [PATCHv2 3/3] validation: dubious bitwise operations with bitwise nots Phil Carmody
2014-06-27 11:19   ` [PATCHv2 0/3] catch non-sign-extended '~' brainos Phil Carmody
2014-06-27 17:16     ` Christopher Li
2014-06-30  8:56       ` Phil Carmody
     [not found]         ` <CANeU7Q=Z=Xac_T3JRAyqo_fF4LAKD-MM41NYz+nDstDutcVUfA@mail.gmail.com>
2014-06-30 17:27           ` Christopher Li
2014-07-01 11:30           ` Phil Carmody
2014-07-01 19:42             ` Christopher Li
2014-07-02  7:43               ` Phil Carmody
2014-07-02  8:51                 ` Christopher Li
2014-07-02  9:28                   ` Phil Carmody

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=20140609133620.GC11986@thin \
    --to=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=phil@dovecot.fi \
    --cc=sparse@chrisli.org \
    /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).