[PATCH v2 08/13] libcacard: Fix bug detected with 'smatch'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Thomas Huth <thuth@xxxxxxxxxxxxxxxxxx>

'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@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]