This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: elfutils-0.157 bug report
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 18 Oct 2013 10:41:10 +0200
- Subject: Re: elfutils-0.157 bug report
Hi David,
On Thu, 2013-10-17 at 20:55 +0000, David Binderman wrote:
> [ar.c:205]: (warning) Logical conjunction always evaluates to false: operation == 7 && operation == 1.
>
> Source code is
>
> if (operation == oper_extract && operation == oper_delete)
>
> Suggest swap && for ||
The cppcheck suggestion is wrong, but the bug is real. I fixed it as
attached. Thanks, please do let us know if you find more issues.
Cheers,
Mark
>From 4f7673f97b5d09db2bc216cc3c46b96e999c15f2 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Fri, 18 Oct 2013 10:37:53 +0200
Subject: [PATCH] ar: Correct operation check when instance_specifed is set.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
src/ChangeLog | 4 ++++
src/ar.c | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index e538a57..72f9924 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2013-10-18 Mark Wielaard <mjw@redhat.com>
+
+ * ar.c (main): Correct operation check when instance_specifed is set.
+
2013-09-26 Petr Machata <pmachata@redhat.com>
* readelf.c (handle_file_note): New function.
diff --git a/src/ar.c b/src/ar.c
index 2d6ad60..f51f0ef 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -202,7 +202,7 @@ MEMBER parameter required for 'a', 'b', and 'i' modifiers"));
if (instance_specifed)
{
/* Only valid for certain operations. */
- if (operation == oper_extract && operation == oper_delete)
+ if (operation != oper_extract && operation != oper_delete)
error (1, 0, gettext ("\
'N' is only meaningful with the 'x' and 'd' options"));
--
1.7.1