From patchwork Tue Jun 27 17:53:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 781319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wxtp15zc5z9s4q for ; Wed, 28 Jun 2017 03:53:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="dAyrJq54"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=nFeu7Oh4HEj4hFkqAnvXMdjCdBKSU dbuK5OJApHt/u9G1yPZ4EKXXoN3HsjmIrP/9Vyu/ONNy8GzRPU0Q7B2kWXZgL98x SOEXJyqWDYbcsvKrJqnhEj+Q+qg+y0RJb1jkWvDVsR7k9RcuMy4wDJ8wFRWR9NNk zx1BTofEcYMazs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=t+mJ89mPxbheAu1wfl/kmXzqcSY=; b=dAy rJq54OYAwLA4eu9oD8WGsWzcvrTS35EVuBfE/nVH5yGlX7Wrn7/n3NJavbGn9dP0 eCLQXnGe0OCPNBa+GFrypuZIdHjK3QUzwc1FoZTMwtrGCpmPHWAtoDuNifmqbzIx XPUc5UVuL7Lhqse/uu0KA9ZXbQjHaOe9ElXnTVO4= Received: (qmail 43596 invoked by alias); 27 Jun 2017 17:53:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 43568 invoked by uid 89); 27 Jun 2017 17:53:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1669 X-HELO: relay1.mentorg.com Date: Tue, 27 Jun 2017 17:53:28 +0000 From: Joseph Myers To: Subject: Fix elf/loadtest.c build with GCC 8 [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Building the testsuite with current GCC mainline fails with: loadtest.c: In function 'main': loadtest.c:76:3: error: macro expands to multiple statements [-Werror=multistatement-macros] for (map = MAPS; map != NULL; map = map->l_next) \ ^ loadtest.c:165:2: note: in expansion of macro 'OUT' OUT; ^~~ loadtest.c:164:7: note: some parts of macro expansion are not guarded by this 'if' clause if (debug) ^~ This seems like a genuine bug, although fairly harmless; it means the fflush call in the OUT macro is unconditional instead of being inside the conditional as presumably intended. This patch makes this macro use do { } while (0) to avoid the problem. Tested for x86_64 (testsuite), and with build-many-glibcs.py for aarch64-linux-gnu with GCC mainline. Committed. 2017-06-27 Joseph Myers * elf/loadtest.c (OUT): Define using do { } while (0). diff --git a/elf/loadtest.c b/elf/loadtest.c index 727469b..b5eab5e 100644 --- a/elf/loadtest.c +++ b/elf/loadtest.c @@ -72,12 +72,16 @@ static const struct #define MAPS ((struct link_map *) _r_debug.r_map) -#define OUT \ - for (map = MAPS; map != NULL; map = map->l_next) \ - if (map->l_type == lt_loaded) \ - printf ("name = \"%s\", direct_opencount = %d\n", \ - map->l_name, (int) map->l_direct_opencount); \ - fflush (stdout) +#define OUT \ + do \ + { \ + for (map = MAPS; map != NULL; map = map->l_next) \ + if (map->l_type == lt_loaded) \ + printf ("name = \"%s\", direct_opencount = %d\n", \ + map->l_name, (int) map->l_direct_opencount); \ + fflush (stdout); \ + } \ + while (0) int