[Spice-devel] [PATCH 07/12] libcacard: Fix bug detected with 'smatch'

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Thu Oct 8 08:40:36 PDT 2015


From: Thomas Huth <thuth at linux.vnet.ibm.com>

'smatch' complains about two bugs and one style issue in card_7816.c:

libcacard/card_7816.c:273 vcard_apdu_set_length() warn: should this be a bitwise op?
libcacard/card_7816.c:295 vcard_apdu_set_length() warn: should this be a bitwise op?
libcacard/card_7816.c:661 vcard7816_vm_process_apdu() warn: inconsistent indenting

... and indeed, the code seems to be wrong here. Let's fix this
by using a bitwise OR instead of logical OR and by indenting
the code with the right level.

Signed-off-by: Thomas Huth <thuth at linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 src/card_7816.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/card_7816.c b/src/card_7816.c
index d168e06..8b12689 100644
--- a/src/card_7816.c
+++ b/src/card_7816.c
@@ -274,7 +274,7 @@ vcard_apdu_set_length(VCardAPDU *apdu)
             }
             /* calculate the first extended value. Could be either Le or Lc */
             Le = (apdu->a_header->ah_body[0] << 8)
-               || apdu->a_header->ah_body[1];
+                | apdu->a_header->ah_body[1];
             if (L == 3) {
                 /* 2E extended, return data only */
                 /*   zero maps to 65536 */
@@ -296,7 +296,7 @@ vcard_apdu_set_length(VCardAPDU *apdu)
             if (L == Le+5) {
                 /* 4E extended, parameters and return data */
                 Le = (apdu->a_data[apdu->a_len-2] << 8)
-                   || apdu->a_data[apdu->a_len-1];
+                    | apdu->a_data[apdu->a_len-1];
                 apdu->a_Le = Le ? Le : 65536;
                 return VCARD7816_STATUS_SUCCESS;
             }
@@ -661,7 +661,7 @@ vcard7816_vm_process_apdu(VCard *card, VCardAPDU *apdu,
                     }
                 }
             } else {
-                    status = vcard_emul_login(card, apdu->a_body, apdu->a_Lc);
+                status = vcard_emul_login(card, apdu->a_body, apdu->a_Lc);
                 *response = vcard_make_response(status);
             }
         }
-- 
2.4.3



More information about the Spice-devel mailing list