The form of if that this warning is looking for is:

if ((n = foo()))

In the warning cases the extra parentheses are totally redundant from a C point 
of view, so the compiler warns as it thinks you were using the parentheses 
since you were doing an =. Actually with warning turned up you need the extra 
parentheses for the above code to not warn. 

The edk2 coding convention is to not do assignments in if/while etc. so these 
warnings are almost always just redundant parentheses. Removing the unneeded 
parentheses makes the warning go away. 

Andrew Fish


On Sep 21, 2012, at 10:42 AM, Sergey Isakov wrote:

> Jordan,
> 
> I can't do a patch because I don't know the right logic of the place
>> } else if (InputString[*Index + StrOffset] == CHAR_LINEFEED)
> 
> or
>> } else if ((InputString[*Index + StrOffset] = CHAR_LINEFEED)) 
> 
> as Andrew noted
> Both way are possible but with different results.
> Hm, I think first way is good.
> 
> On 21.09.2012, at 20:20, Sergey Isakov <[email protected]> wrote:
> 
>> Dear MdeModulePkg maintainers,
>> Correct please the error
>> --------------
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1458:47: 
>> error: equality comparison with extraneous parentheses 
>> [-Werror,-Wparentheses-equality]
>> } else if ((InputString[*Index + StrOffset] == CHAR_LINEFEED)) {
>>             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1458:47: 
>> note: remove extraneous parentheses around the comparison to silence this 
>> warning
>> } else if ((InputString[*Index + StrOffset] == CHAR_LINEFEED)) {
>>            ~                                ^               ~
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1458:47: 
>> note: use '=' to turn this equality comparison into an assignment
>> } else if ((InputString[*Index + StrOffset] == CHAR_LINEFEED)) {
>>                                             ^~
>>                                             =
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1467:47: 
>> error: equality comparison with extraneous parentheses 
>> [-Werror,-Wparentheses-equality]
>> } else if ((InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN)) {
>>             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1467:47: 
>> note: remove extraneous parentheses around the comparison to silence this 
>> warning
>> } else if ((InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN)) {
>>            ~                                ^                      ~
>> /Users/sergey/src/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c:1467:47: 
>> note: use '=' to turn this equality comparison into an assignment
>> } else if ((InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN)) {
>>                                             ^~
>> --------------
>> As far as I understand we just have to remove double braces.
>> 
>> Sergey
>> ------------------------------------------------------------------------------
>> Got visibility?
>> Most devs has no idea what their production app looks like.
>> Find out how fast your code is with AppDynamics Lite.
>> http://ad.doubleclick.net/clk;262219671;13503038;y?
>> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
>> _______________________________________________
>> edk2-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
> 
> 
> ------------------------------------------------------------------------------
> Got visibility?
> Most devs has no idea what their production app looks like.
> Find out how fast your code is with AppDynamics Lite.
> http://ad.doubleclick.net/clk;262219671;13503038;y?
> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to