From patchwork Thu Mar 19 14:53:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 452005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BFCE81400D5 for ; Fri, 20 Mar 2015 02:05:57 +1100 (AEDT) Received: from localhost ([::1]:39663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYc1D-0004tC-ME for incoming@patchwork.ozlabs.org; Thu, 19 Mar 2015 11:05:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYc0k-0004az-E5 for qemu-devel@nongnu.org; Thu, 19 Mar 2015 11:05:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYc0b-0003sm-UD for qemu-devel@nongnu.org; Thu, 19 Mar 2015 11:05:26 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:52871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYc0b-0003sZ-L9 for qemu-devel@nongnu.org; Thu, 19 Mar 2015 11:05:17 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Mar 2015 14:55:03 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Mar 2015 14:55:02 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6517F17D8019 for ; Thu, 19 Mar 2015 14:55:27 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2JEt2Oa12255510 for ; Thu, 19 Mar 2015 14:55:02 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2JEt1pW025582 for ; Thu, 19 Mar 2015 08:55:01 -0600 Received: from oc7435384737.ibm.com (dyn-9-152-224-100.boeblingen.de.ibm.com [9.152.224.100]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2JEt1M2025556; Thu, 19 Mar 2015 08:55:01 -0600 From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 19 Mar 2015 15:53:50 +0100 Message-Id: <1426776830-31961-1-git-send-email-thuth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15031914-0017-0000-0000-0000036FC80E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.110 Cc: alevy@redhat.com, armbru@redhat.com, Thomas Huth Subject: [Qemu-devel] [RFC PATCH] libcacard: Fix bug detected with 'smatch' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org '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 --- Please note that this is compile-tested only. I don't have a clue about that libcacard stuff, so if you feel confident in this area, please have a look whether this change really makes sense. --- libcacard/card_7816.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c index 814fa16..0f7a006 100644 --- a/libcacard/card_7816.c +++ b/libcacard/card_7816.c @@ -270,7 +270,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 */ @@ -292,7 +292,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; } @@ -657,7 +657,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); } }