From patchwork Thu Nov 12 09:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1398789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=RqKd+qst; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CWxBV50jbz9s1l for ; Thu, 12 Nov 2020 20:29:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86C3739F6E4B; Thu, 12 Nov 2020 09:29:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86C3739F6E4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605173359; bh=CBuSr34K9wqOfy56JXuaSca0NIJKuPaRF3c9WekDiuc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=RqKd+qsta4xfmavHhgLwaLMnn35JXRfmpN6kWyMHXHINsHwYjbN3B9cptMFC5twNF w2d7HcO0wKfQKJVnvELQbGUDmyyX86EP/7XwIeH9XsHI/NKC+Fe8kMoHOeZIMtWwt9 02w9P4HzEY1lZxfPyjTWDFxdnhq/OUDffkdbkKhU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bumble.maple.relay.mailchannels.net (bumble.maple.relay.mailchannels.net [23.83.214.25]) by sourceware.org (Postfix) with ESMTPS id 1468E39F6E4B for ; Thu, 12 Nov 2020 09:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1468E39F6E4B X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A512F64076F; Thu, 12 Nov 2020 09:29:15 +0000 (UTC) Received: from pdx1-sub0-mail-a27.g.dreamhost.com (100-96-22-162.trex.outbound.svc.cluster.local [100.96.22.162]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4436D640414; Thu, 12 Nov 2020 09:29:15 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a27.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.10); Thu, 12 Nov 2020 09:29:15 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Irritate-Broad: 7397e9c203fe74da_1605173355526_3103284992 X-MC-Loop-Signature: 1605173355525:187871460 X-MC-Ingress-Time: 1605173355525 Received: from pdx1-sub0-mail-a27.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTP id F2D587F693; Thu, 12 Nov 2020 01:29:14 -0800 (PST) Received: from rhbox.redhat.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTPSA id 6D7907F696; Thu, 12 Nov 2020 01:29:11 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a27 To: libc-alpha@sourceware.org Subject: [COMMITTED v2] Don't use nested function in test-ffs Date: Thu, 12 Nov 2020 14:59:05 +0530 Message-Id: <20201112092905.2221021-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <87lff7ymkw.fsf@oldenburg2.str.redhat.com> References: <87lff7ymkw.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is what I committed based on your suggestion Florian. Thanks, Siddhesh There is no real need to use a nested function in that test, so break it out so that it can build with clang too. --- string/test-ffs.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/string/test-ffs.c b/string/test-ffs.c index 0df488fa2b..af03df90a1 100644 --- a/string/test-ffs.c +++ b/string/test-ffs.c @@ -20,28 +20,25 @@ #include #include #include +#include + +void try (const char *name, long long int param, int value, int expected) +{ + if (value != expected) + { + printf ("%s(%#llx) expected %d got %d\n", + name, param, expected, value); + support_record_failure (); + } + else + printf ("%s(%#llx) as expected %d\n", name, param, value); +} int do_test (void) { - int failures = 0; int i; - auto void try (const char *name, long long int param, int value, - int expected); - - void try (const char *name, long long int param, int value, int expected) - { - if (value != expected) - { - printf ("%s(%#llx) expected %d got %d\n", - name, param, expected, value); - ++failures; - } - else - printf ("%s(%#llx) as expected %d\n", name, param, value); - } - #define TEST(fct, type) \ try (#fct, 0, fct ((type) 0), 0); \ for (i=0 ; i < 8 * sizeof (type); i++) \ @@ -54,12 +51,7 @@ do_test (void) TEST (ffsl, long int); TEST (ffsll, long long int); - if (failures) - printf ("Test FAILED! %d failure%s.\n", failures, &"s"[failures == 1]); - else - puts ("Test succeeded."); - - return failures; + return 0; } #include