From: Christopher Li <sparse@chrisli.org>
To: Chris Forbes <chrisf@ijw.co.nz>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1/3] evaluate: warn on identical exprs around '&&'
Date: Tue, 30 Aug 2011 17:24:55 -0700 [thread overview]
Message-ID: <CANeU7QkM+Umno8n5tpVBvrBit_RMphOqqkODKkoxM9SNUCRfUA@mail.gmail.com> (raw)
In-Reply-To: <1314484015-7694-1-git-send-email-chrisf@ijw.co.nz>
On Sat, Aug 27, 2011 at 3:26 PM, Chris Forbes <chrisf@ijw.co.nz> wrote:
> Adds a warning when identical expressions are found on both sides of the '&&' operator. This is a common error resulting from copy & paste.
>
> Excludes identical expressions found while preprocessing, so we don't get upset about #if defined(FOO) && defined(BAR), which happens all the time, and is perfectly valid.
I create a branch for the identical expression check.
http://git.kernel.org/?p=devel/sparse/chrisl/sparse.git;a=shortlog;h=refs/heads/warn-equiv-expr
I did not plan to include it in this 0.4.4 release yet.
For now bug fix only.
I also want to see how it perform on project source code.
It is adding complexity and CPU run time to sparse, I like to see some
results.
> +static int ident_equal(struct ident *a, struct ident *b)
> +{
> + /* only correct when used in the context of expr_equiv.
> + should compare symbols? for general case? */
> + return a->len == b->len &&
> + !memcmp(a->name, b->name, a->len);
> +}
The ident_equal is overkill. The ident has been hashed and guarantee
unique.
You only need to compare pointer a == b. The whole point of
ident hashing is to reduce memcmp.
Chris
next prev parent reply other threads:[~2011-08-31 0:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-27 22:26 [PATCH 1/3] evaluate: warn on identical exprs around '&&' Chris Forbes
2011-08-27 22:26 ` [PATCH 2/3] evaluate: warn on identical exprs around '||' Chris Forbes
2011-08-27 22:26 ` [PATCH 3/3] evaluate: warn on identical exprs on ?: Chris Forbes
2011-08-28 2:46 ` Josh Triplett
2011-08-28 2:51 ` Chris Forbes
2011-08-28 2:50 ` [PATCH 1/3] evaluate: warn on identical exprs around '&&' Josh Triplett
2011-08-28 2:53 ` Chris Forbes
2011-08-28 3:33 ` Josh Triplett
2011-08-28 2:57 ` Chris Forbes
2011-08-28 3:36 ` Josh Triplett
2011-08-31 0:24 ` Christopher Li [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-08-28 3:14 Chris Forbes
2011-08-29 10:01 ` Jonathan Neuschäfer
2011-08-29 10:25 ` Josh Triplett
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=CANeU7QkM+Umno8n5tpVBvrBit_RMphOqqkODKkoxM9SNUCRfUA@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=chrisf@ijw.co.nz \
--cc=linux-sparse@vger.kernel.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).