linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	linux-sparse@vger.kernel.org, josh@joshtriplett.org,
	"Marcos A. Di Pietro" <marcosadp@gmail.com>
Subject: Re: [PATCH] Staging/comedi: Fixes static analysis warning raised by sparse
Date: Mon, 16 Jun 2014 10:40:19 +0300	[thread overview]
Message-ID: <20140616074019.GL5015@mwanda> (raw)
In-Reply-To: <20140615193227.GA24515@ravnborg.org>

On Sun, Jun 15, 2014 at 09:32:27PM +0200, Sam Ravnborg wrote:
> diff --git a/expand.c b/expand.c
> index 0f6720c..4a96de4 100644
> --- a/expand.c
> +++ b/expand.c
> @@ -187,7 +187,7 @@ static int simplify_int_binop(struct expression *expr, struct symbol *ctype)
>  		return 0;
>  	r = right->value;
>  	if (expr->op == SPECIAL_LEFTSHIFT || expr->op == SPECIAL_RIGHTSHIFT) {
> -		if (r >= ctype->bit_size) {
> +		if (expr->flags & Int_const_expr && r >= ctype->bit_size) {

Thanks!  I had no idea how to start writing a fix for this, but the test
should be:
		if (expr->right->flags & Int_const_expr

Otherwise both sides of the shift have to be const.

>  			if (conservative)
>  				return 0;
>  			r = check_shift_count(expr, ctype, r);
> 

regards,
dan carpenter

  reply	other threads:[~2014-06-16  7:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <53965E53.5080504@gmail.com>
     [not found] ` <20140610054741.GE5500@mwanda>
     [not found]   ` <DC148C5AA1CEBA4E87973D432B1C2D8825E9AE6A@P3PWEX4MB008.ex4.secureserver.net>
     [not found]     ` <20140611065612.GQ5015@mwanda>
     [not found]       ` <DC148C5AA1CEBA4E87973D432B1C2D8825E9CBD6@P3PWEX4MB008.ex4.secureserver.net>
2014-06-11 21:24         ` [PATCH] Staging/comedi: Fixes static analysis warning raised by sparse Dan Carpenter
2014-06-11 21:45           ` josh
2014-06-15 19:32             ` Sam Ravnborg
2014-06-16  7:40               ` Dan Carpenter [this message]
2014-06-16  8:06                 ` Sam Ravnborg
2014-06-28 18:07             ` Christopher Li
2014-06-28 19:20               ` Josh Triplett
2014-06-29  3:09                 ` Christopher Li
2014-06-30 17:49                   ` Christopher Li
2014-06-30 18:32                     ` Christopher Li

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=20140616074019.GL5015@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=marcosadp@gmail.com \
    --cc=sam@ravnborg.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).