From patchwork Thu Feb 7 23:07:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1038393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99860-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="VJJFW6Eo"; dkim-atps=neutral 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 43wYqT6QlVz9s9G for ; Fri, 8 Feb 2019 10:07:17 +1100 (AEDT) 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=gSdvPUeUkBzRwSrznP3V7MiIvmhFh /VPaVCu7upx+MksCDy7YdTgMDD6VQ9Gzh1H7TpQztK5Nsx0OW2oY0EwD+RgC50XV lU9JlAupxxQwmfiejd5t7JjvgqQvPVXvVq//ZJP2Qc4VHs+N6Be006fp0TFGHcxo gQxzZSKevI7eIo= 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=nrCo5MKBTzLpjKZ5BvoUEZTss3s=; b=VJJ FW6EogGjssVKQd7paXBS/ZXXXpEm3lxmpc8LzEhldPePAJIfI5k+PREdY+p/YJzS YZpwvhuDkMZ+5g0cdQNEmIV7Mm4KIJNjVp6QM/XfLFgkGwJmBLV+UX2s5bMZVb2L loG7NRB4VGsSCtrmRh1+UDc1GersrZbq6WcDvt2E= Received: (qmail 58148 invoked by alias); 7 Feb 2019 23:07:11 -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 58124 invoked by uid 89); 7 Feb 2019 23:07:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 7 Feb 2019 23:07:01 +0000 From: Joseph Myers To: Subject: Fix -Wempty-body warnings in glibc Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 One group of warnings seen building glibc with -Wextra is -Wempty-body warnings about an 'if' body (or in one case an 'else' body) that is just a semicolon, "warning: suggest braces around empty body in an 'if' statement [-Wempty-body]" - I think the point of the warning being to make it more visible whether an 'if' body is actually present or not. This patch fixes such warnings in glibc. There's one place, with a semicolon at the end of a comment, where this is clearly making the presence of an 'else' body more visible. The other cases involve macro definitions expanding to nothing. While there's no issue there with visibility at the call sites, I think it's still cleaner to have a macro that expands to something nonempty appropriate for the context - so do {} while (0) if it's only intended to be usable as a statement, or ((void) 0) where the macro definition is an alternative to a call to a function returning void, so this patch makes those changes. Tested for x86_64. 2019-02-07 Joseph Myers * catgets/gencat.c (normalize_line): Use braces around empty 'else' body. * include/stap-probe.h [!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE0): Use do {} while (0) for do-nothing definition. [!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE1): Likewise. [!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE2): Likewise. [!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE3): Likewise. [!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE4): Likewise. * libio/libio.h (_IO_funlockfile): Use ((void) 0) for do-nothing definition. diff --git a/catgets/gencat.c b/catgets/gencat.c index 9d6db7017e..51fd2a724e 100644 --- a/catgets/gencat.c +++ b/catgets/gencat.c @@ -1196,7 +1196,9 @@ normalize_line (const char *fname, size_t line, iconv_t cd, wchar_t *string, ++rp; } else - /* Simply ignore the backslash character. */; + { + /* Simply ignore the backslash character. */ + } break; } } diff --git a/include/stap-probe.h b/include/stap-probe.h index 8c26292edd..85f41c9162 100644 --- a/include/stap-probe.h +++ b/include/stap-probe.h @@ -60,11 +60,11 @@ /* Evaluate all the arguments and verify that N matches their number. */ # define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__) -# define STAP_PROBE0() -# define STAP_PROBE1(a1) -# define STAP_PROBE2(a1, a2) -# define STAP_PROBE3(a1, a2, a3) -# define STAP_PROBE4(a1, a2, a3, a4) +# define STAP_PROBE0() do {} while (0) +# define STAP_PROBE1(a1) do {} while (0) +# define STAP_PROBE2(a1, a2) do {} while (0) +# define STAP_PROBE3(a1, a2, a3) do {} while (0) +# define STAP_PROBE4(a1, a2, a3, a4) do {} while (0) # else # define LIBC_PROBE(name, n, ...) /* Nothing. */ diff --git a/libio/libio.h b/libio/libio.h index d21162aab0..9c08c7eba1 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -240,7 +240,7 @@ extern int _IO_ftrylockfile (FILE *) __THROW; #define _IO_peekc(_fp) _IO_peekc_unlocked (_fp) #define _IO_flockfile(_fp) /**/ -#define _IO_funlockfile(_fp) /**/ +#define _IO_funlockfile(_fp) ((void) 0) #define _IO_ftrylockfile(_fp) /**/ #ifndef _IO_cleanup_region_start #define _IO_cleanup_region_start(_fct, _fp) /**/