[FFmpeg-devel] [PATCH] Tell gcc not to "suggest" unnecessary parentheses
Eli Friedman
eli.friedman
Thu Jul 8 07:01:42 CEST 2010
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.
-Eli
More information about the ffmpeg-devel
mailing list