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

Michael Niedermayer michaelni
Wed Jul 7 12:17:28 CEST 2010


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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- 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/20100707/f9f06133/attachment.pgp>



More information about the ffmpeg-devel mailing list