[FFmpeg-devel] [PATCH] Tell gcc not to "suggest" unnecessary parentheses

Michael Niedermayer michaelni
Fri Jul 9 03:11:22 CEST 2010


On Wed, Jul 07, 2010 at 10:01:42PM -0700, Eli Friedman wrote:
> On Wed, Jul 7, 2010 at 3:17 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Tue, Jul 06, 2010 at 12:18:18PM -0700, Eli Friedman wrote:
> >> On Sat, Jul 3, 2010 at 12:59 PM, Rafa?l Carr? <rafael.carre at gmail.com> wrote:
> >> > On Sat, 3 Jul 2010 12:20:17 -0700
> >> > Eli Friedman <eli.friedman at gmail.com> wrote:
> >> >
> >> > Hi,
> >> >
> >> >> >> If I may give a suggestion, keep the warning as it can help
> >> >> >> spotting
> >> >> >>
> >> >> >> if ( foo = 1 )
> >> >> >>
> >> >> >> where the assignment wasn't intended.
> >> >> >
> >> >> > does our patcheck check for this?
> >> >>
> >> >> Not at the moment... I'd write a patch, but my regex skills aren't
> >> >> quite up to the task.
> >> >
> >> > I think "[^\(]\([^\(].*[^=]=[^=]" should do the trick:
> >> >
> >> > It should match one single opening parenthesis and one single = in the
> >> > same line.
> >> >
> >> > Depending on code conventions it could have some false positives like:
> >> > if ? ? ?(AAA ? ?&& ? ? ?\
> >> > ? ? ? ?(x = y) && ? ? ?\
> >> > ? ? ? ?BBB)
> >>
> >> Limited patch attached... it's really difficult to catch everything
> >> with regexes, but this should catch the most common cases (with some
> >> false positives if people like writing "if (x) y=z;" on one line).
> >
> > you arent limited to grep regex, you can use anything else too
> >
> > also i think a false positive for if (x) y=z could be annoying
> 
> My shell scripting skills are a bit lacking for anything much more
> complicated than that.

try:
(if|while) *([^(=]*=[^)=]*)

(yes i made no attempt to add needed escaping)

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100709/c6f94609/attachment.pgp>



More information about the ffmpeg-devel mailing list