From patchwork Sat Jun 22 09:24:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 253405 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 571002C0415 for ; Sat, 22 Jun 2013 19:34:03 +1000 (EST) Received: from localhost ([::1]:39896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqKCn-0002GU-7M for incoming@patchwork.ozlabs.org; Sat, 22 Jun 2013 05:34:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqKCG-0002Es-5f for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:33:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqKCF-0007sv-0K for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:33:27 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:52141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqKCE-0007rV-P5 for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:33:26 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id B474141E3F; Sat, 22 Jun 2013 13:33:25 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id A10C4565; Sat, 22 Jun 2013 13:24:39 +0400 (MSK) From: Michael Tokarev To: Anthony Liguori Date: Sat, 22 Jun 2013 13:24:25 +0400 Message-Id: <1371893076-9643-7-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371893076-9643-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1371893076-9643-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: Stefan Weil , Michael Tokarev , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 06/17] libcacard: Fix cppcheck warning and remove unneeded code 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 From: Stefan Weil The local function vcard_emul_alloc_arrays always returned PR_TRUE. Therefore cppcheck complained about code which handled the non-existent PR_FALSE case. Remove the function's return value and the dead code. Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- libcacard/vcard_emul_nss.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index 1a3e568..fb429b1 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -90,17 +90,13 @@ static int nss_emul_init; /* * allocate the set of arrays for certs, cert_len, key */ -static PRBool +static void vcard_emul_alloc_arrays(unsigned char ***certsp, int **cert_lenp, VCardKey ***keysp, int cert_count) { - *certsp = NULL; - *cert_lenp = NULL; - *keysp = NULL; *certsp = (unsigned char **)g_malloc(sizeof(unsigned char *)*cert_count); *cert_lenp = (int *)g_malloc(sizeof(int)*cert_count); *keysp = (VCardKey **)g_malloc(sizeof(VCardKey *)*cert_count); - return PR_TRUE; } /* @@ -601,7 +597,6 @@ vcard_emul_mirror_card(VReader *vreader) int *cert_len; VCardKey **keys; PK11SlotInfo *slot; - PRBool ret; VCard *card; slot = vcard_emul_reader_get_slot(vreader); @@ -627,10 +622,7 @@ vcard_emul_mirror_card(VReader *vreader) } /* allocate the arrays */ - ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count); - if (ret == PR_FALSE) { - return NULL; - } + vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count); /* fill in the arrays */ cert_count = 0; @@ -878,7 +870,7 @@ VCardEmulError vcard_emul_init(const VCardEmulOptions *options) { SECStatus rv; - PRBool ret, has_readers = PR_FALSE; + PRBool has_readers = PR_FALSE; VReader *vreader; VReaderEmul *vreader_emul; SECMODListLock *module_lock; @@ -944,11 +936,9 @@ vcard_emul_init(const VCardEmulOptions *options) vreader_add_reader(vreader); cert_count = options->vreader[i].cert_count; - ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys, - options->vreader[i].cert_count); - if (ret == PR_FALSE) { - continue; - } + vcard_emul_alloc_arrays(&certs, &cert_len, &keys, + options->vreader[i].cert_count); + cert_count = 0; for (j = 0; j < options->vreader[i].cert_count; j++) { /* we should have a better way of identifying certs than by