abipkgdiff: Address operator precedence warning

Message ID 20210126095655.2964881-1-maennich@google.com
State Committed
Headers
Series abipkgdiff: Address operator precedence warning |

Commit Message

Matthias Männich Jan. 26, 2021, 9:56 a.m. UTC
  When compiling with clang, it (rightfully) complains about an operator
precedence issue:

abipkgdiff.cc:1646:7: error: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
      ? string("Comparison against self SUCCEEDED\n")
      ^

Fix that by properly placing the parentheses. Also, drop the superfluous
string conversion.

	* tools/abipkgdiff.cc (compare_to_self): address clang warning.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 tools/abipkgdiff.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Giuliano Procida Jan. 26, 2021, 11:54 a.m. UTC | #1
On Tue, 26 Jan 2021 at 09:57, Matthias Maennich <maennich@google.com> wrote:
>
> When compiling with clang, it (rightfully) complains about an operator
> precedence issue:
>
> abipkgdiff.cc:1646:7: error: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
>       ? string("Comparison against self SUCCEEDED\n")
>       ^
>
> Fix that by properly placing the parentheses. Also, drop the superfluous
> string conversion.
>
>         * tools/abipkgdiff.cc (compare_to_self): address clang warning.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>
Reviewed-by: Giuliano Procida <gprocida@google.com>

Looks good to me.

> ---
>  tools/abipkgdiff.cc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
> index 783a8d9a5359..c2badadb5973 100644
> --- a/tools/abipkgdiff.cc
> +++ b/tools/abipkgdiff.cc
> @@ -1642,9 +1642,9 @@ compare_to_self(const elf_file& elf,
>
>    if (opts.verbose)
>      emit_prefix("abipkgdfiff", cerr)
> -      << (s == abigail::tools_utils::ABIDIFF_OK)
> -      ? string("Comparison against self SUCCEEDED\n")
> -      : string("Comparison against self FAILED\n");
> +      << "Comparison against self "
> +      << (s == abigail::tools_utils::ABIDIFF_OK ? "SUCCEEDED" : "FAILED")
> +      << '\n';
>    return s;
>  }
>
> --
> 2.30.0.280.ga3ce27912f-goog
>
  
Dodji Seketeli Jan. 26, 2021, 4:22 p.m. UTC | #2
Giuliano Procida <gprocida@google.com> a écrit:

> On Tue, 26 Jan 2021 at 09:57, Matthias Maennich <maennich@google.com> wrote:
>>
>> When compiling with clang, it (rightfully) complains about an operator
>> precedence issue:
>>
>> abipkgdiff.cc:1646:7: error: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
>>       ? string("Comparison against self SUCCEEDED\n")
>>       ^
>>
>> Fix that by properly placing the parentheses. Also, drop the superfluous
>> string conversion.
>>
>>         * tools/abipkgdiff.cc (compare_to_self): address clang warning.
>>
>> Signed-off-by: Matthias Maennich <maennich@google.com>
> Reviewed-by: Giuliano Procida <gprocida@google.com>
>
> Looks good to me.

Applied to master, thanks!

Cheers,
  

Patch

diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
index 783a8d9a5359..c2badadb5973 100644
--- a/tools/abipkgdiff.cc
+++ b/tools/abipkgdiff.cc
@@ -1642,9 +1642,9 @@  compare_to_self(const elf_file& elf,
 
   if (opts.verbose)
     emit_prefix("abipkgdfiff", cerr)
-      << (s == abigail::tools_utils::ABIDIFF_OK)
-      ? string("Comparison against self SUCCEEDED\n")
-      : string("Comparison against self FAILED\n");
+      << "Comparison against self "
+      << (s == abigail::tools_utils::ABIDIFF_OK ? "SUCCEEDED" : "FAILED")
+      << '\n';
   return s;
 }