diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2015-10-20 16:14:21 -0400 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-10-20 23:44:06 +0000 |
commit | 4a5977b587deeca40d9bbdd55a0ebf3f33059372 (patch) | |
tree | 4af8a70e91c1e57b34c2badaf1978b59240e6b98 /tools/process-x11-xcb.pl | |
parent | 9768a3e8a06d7a8fd8b5751ef24a1279446ba933 (diff) | |
download | wireshark-4a5977b587deeca40d9bbdd55a0ebf3f33059372.tar.gz |
X11 generator: avoid extraneous parens in conditionals.
This is to avoid complaints from clang of the form:
wireshark/epan/dissectors/x11-extension-implementation.h:17021:18: error:
equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
if ((f_class_id == 0)) {
~~~~~~~~~~~^~~~
Change-Id: I91d629ad47677b71909d7da517c4a6198c276186
Reviewed-on: https://code.wireshark.org/review/11186
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'tools/process-x11-xcb.pl')
-rwxr-xr-x | tools/process-x11-xcb.pl | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/process-x11-xcb.pl b/tools/process-x11-xcb.pl index 80c8d7f4d9..4687e79e70 100755 --- a/tools/process-x11-xcb.pl +++ b/tools/process-x11-xcb.pl @@ -902,17 +902,30 @@ sub dissect_element($$$$$;$$) for my $foo (keys %{$enum{$enum_name{$enum_ref}}{rbit}}) { say "'$foo'"; } die ("Field '$field' not found in '$enum_ref'"); } - push @test , "($switchon & (1U << $bit))"; + push @test , "$switchon & (1U << $bit)"; } else { my $val = $enum{$enum_name{$enum_ref}}{rvalue}{$field}; if (! defined($val)) { for my $foo (keys %{$enum{$enum_name{$enum_ref}}{rvalue}}) { say "'$foo'"; } die ("Field '$field' not found in '$enum_ref'"); } - push @test , "($switchon == $val)"; + push @test , "$switchon == $val"; } } - my $list = join ' || ', @test; + + if (@test > 1) { + # We have more than one conditional, add parentheses to them. + # We don't add parentheses to all the conditionals because + # clang complains about the extra parens if you do "if ((x == y))". + my @tests_with_parens; + foreach my $conditional (@test) { + push @tests_with_parens, "($conditional)"; + } + + @test = @tests_with_parens; + } + + my $list = join ' || ', @test; say $impl $indent."if ($list) {"; my $vp = $varpat; |