Re: [PATCH 1/3] evaluate: warn on identical exprs around '&&'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 27, 2011 at 3:26 PM, Chris Forbes <chrisf@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux