From patchwork Thu Nov 12 07:57:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41025 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92B013851C34; Thu, 12 Nov 2020 07:57:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92B013851C34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605167875; bh=Vmc1tmXtnEYzt1gNR581AmYjT4S0wee5ISytAzO1Puo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=byrryyjJbGurZFcOHHOywUUGWICT+6qeMjdyHGoyDgtUiWicqR25Mwl5V5s+GHzjX 4taGCx5k65T+wJspuaZZzzUagUooD4PRV34iLgWthhft1B7EnQhvRS8zbM3Cp2v26g 57QgB2V9XQA3C6dLuk3GFjhLqFrb9xiRegy5s4+o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dragonfly.birch.relay.mailchannels.net (dragonfly.birch.relay.mailchannels.net [23.83.209.51]) by sourceware.org (Postfix) with ESMTPS id EACBD3851C34 for ; Thu, 12 Nov 2020 07:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EACBD3851C34 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 B59CC400E40 for ; Thu, 12 Nov 2020 07:57:51 +0000 (UTC) Received: from pdx1-sub0-mail-a27.g.dreamhost.com (100-98-64-63.trex.outbound.svc.cluster.local [100.98.64.63]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 43014401990 for ; Thu, 12 Nov 2020 07:57:51 +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 07:57:51 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Dime-Keen: 2e14c6805a3f8d9e_1605167871492_511844992 X-MC-Loop-Signature: 1605167871492:3582712519 X-MC-Ingress-Time: 1605167871491 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 0BD5F8876D for ; Wed, 11 Nov 2020 23:57:51 -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 DC1AA7F696 for ; Wed, 11 Nov 2020 23:57:49 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a27 To: libc-alpha@sourceware.org Subject: [PATCH] Don't use nested function in test-ffs Date: Thu, 12 Nov 2020 13:27:41 +0530 Message-Id: <20201112075741.2172210-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.26.2 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 Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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 | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/string/test-ffs.c b/string/test-ffs.c index 0df488fa2b..a2a606522a 100644 --- a/string/test-ffs.c +++ b/string/test-ffs.c @@ -21,34 +21,33 @@ #include #include +void try (const char *name, long long int param, int value, int expected, + int *failuresp) +{ + if (value != expected) + { + printf ("%s(%#llx) expected %d got %d\n", + name, param, expected, value); + *failuresp += 1; + } + 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); \ + try (#fct, 0, fct ((type) 0), 0, &failures); \ for (i=0 ; i < 8 * sizeof (type); i++) \ - try (#fct, 1ll << i, fct (((type) 1) << i), i + 1); \ + try (#fct, 1ll << i, fct (((type) 1) << i), i + 1, &failures); \ for (i=0 ; i < 8 * sizeof (type) ; i++) \ - try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\ - try (#fct, 0x80008000, fct ((type) 0x80008000), 16) + try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1, \ + &failures); \ + try (#fct, 0x80008000, fct ((type) 0x80008000), 16, &failures) TEST (ffs, int); TEST (ffsl, long int);