All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Stafford Horne <shorne@gmail.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 4/4] bad-shift: wait dead code elimination to warn about bad shifts
Date: Sat, 15 Aug 2020 13:15:40 +0200	[thread overview]
Message-ID: <20200815111540.nxdsfzurv555qpap@ltop.local> (raw)
In-Reply-To: <20200815095703.GU80756@lianli.shorne-pla.net>

On Sat, Aug 15, 2020 at 06:57:03PM +0900, Stafford Horne wrote:
> On Thu, Aug 06, 2020 at 09:30:03PM +0200, Luc Van Oostenryck wrote:
> > --- a/linearize.c
> > +++ b/linearize.c
> > @@ -2468,6 +2468,49 @@ static pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stm
> >  	return VOID;
> >  }
> >  
> > +static void check_tainted_insn(struct instruction *insn)
> > +{
> > +	unsigned long long uval;
> > +	long long sval;
> > +	pseudo_t src2;
> > +
> > +	switch (insn->opcode) {
> > +	case OP_DIVU: case OP_DIVS:
> > +	case OP_MODU: case OP_MODS:
> > +		if (insn->src2 == value_pseudo(0))
> > +			warning(insn->pos, "divide by zero");
> > +		break;
> 
> Is this divide by zero a new check?  I get the shift, but is this new?

Yes, and no. The warning is already given (using 'division by zero')
but, like for shifts before this series, issued early, before dead code
elimination is done. So, code like the following:
	...
	if (d != 0)
		r = a / d;
	...
issues the warning nevertheless. So, the check here above is now unused
but is a preparation for the part 2 doing the same for division by zero
by zero.

Best regards,
-- Luc

  reply	other threads:[~2020-08-15 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 19:29 [PATCH 0/4] Fix shifts-assigns and avoid warns on deadcode Luc Van Oostenryck
2020-08-06 19:30 ` [PATCH 1/4] shift-assign: add more testcases for bogus linearization Luc Van Oostenryck
2020-08-06 19:30 ` [PATCH 2/4] shift-assign: fix linearization of shift-assign Luc Van Oostenryck
2020-08-06 19:30 ` [PATCH 3/4] shift-assign: restrict shift count to unsigned int Luc Van Oostenryck
2020-08-06 19:30 ` [PATCH 4/4] bad-shift: wait dead code elimination to warn about bad shifts Luc Van Oostenryck
2020-08-15  9:57   ` Stafford Horne
2020-08-15 11:15     ` Luc Van Oostenryck [this message]
2020-08-15 13:51       ` Stafford Horne
2020-08-15  9:59 ` [PATCH 0/4] Fix shifts-assigns and avoid warns on deadcode Stafford Horne
2020-08-15 11:03   ` Luc Van Oostenryck

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=20200815111540.nxdsfzurv555qpap@ltop.local \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=shorne@gmail.com \
    /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.