From patchwork Mon Feb 26 10:34:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 10241995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 864B3602DC for ; Mon, 26 Feb 2018 10:34:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 679E229F38 for ; Mon, 26 Feb 2018 10:34:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C2D429F3A; Mon, 26 Feb 2018 10:34:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C029F29F38 for ; Mon, 26 Feb 2018 10:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbeBZKef (ORCPT ); Mon, 26 Feb 2018 05:34:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:56024 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751796AbeBZKee (ORCPT ); Mon, 26 Feb 2018 05:34:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 59B2CAB34; Mon, 26 Feb 2018 10:34:33 +0000 (UTC) Date: Mon, 26 Feb 2018 11:34:31 +0100 From: Jean Delvare To: linux-acpi@vger.kernel.org, devel@acpica.org Cc: Len Brown , "Rafael J. Wysocki" , Robert Moore , Erik Schmauss Subject: [PATCH] ACPICA: Silent warnings about empty body in if/else statement Message-ID: <20180226113431.3e43a032@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When ACPI debugging is disabled, I see warnings like this one: drivers/i2c/busses/i2c-scmi.c: In function "acpi_smbus_cmi_add_cap": drivers/i2c/busses/i2c-scmi.c:328:39: warning: suggest braces around empty body in an "else" statement [-Wempty-body] drivers/i2c/busses/i2c-scmi.c:338:12: warning: suggest braces around empty body in an "else" statement [-Wempty-body] It is caused by ACPI_DEBUG_PRINT (or other similar macros) resolving to nothing. Make them resolve to the classic "do {} while (0)" construct instead if the compiler likes that, or just {} if not, to silent all such warnings. Signed-off-by: Jean Delvare Cc: Len Brown Cc: "Rafael J. Wysocki" Cc: Robert Moore Cc: Erik Schmauss --- include/acpi/acoutput.h | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) --- linux-4.16-rc3.orig/include/acpi/acoutput.h 2018-02-26 10:57:56.803381047 +0100 +++ linux-4.16-rc3/include/acpi/acoutput.h 2018-02-26 11:16:41.569185359 +0100 @@ -249,6 +249,17 @@ #endif /* ACPI_NO_ERROR_MESSAGES */ /* + * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from + * complaining about these constructs. On other compilers the do...while + * adds some extra code, so this feature is optional. + */ +#ifdef ACPI_USE_DO_WHILE_0 +#define ACPI_DO_WHILE0(a) do a while (0) +#else +#define ACPI_DO_WHILE0(a) a +#endif + +/* * Debug macros that are conditionally compiled */ #ifdef ACPI_DEBUG_OUTPUT @@ -297,16 +308,7 @@ * debug message outside of the print function itself. This improves overall * performance at a relatively small code cost. Implementation involves the * use of variadic macros supported by C99. - * - * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from - * complaining about these constructs. On other compilers the do...while - * adds some extra code, so this feature is optional. */ -#ifdef ACPI_USE_DO_WHILE_0 -#define ACPI_DO_WHILE0(a) do a while(0) -#else -#define ACPI_DO_WHILE0(a) a -#endif /* DEBUG_PRINT functions */ @@ -458,23 +460,23 @@ * This is the non-debug case -- make everything go away, * leaving no executable debug code! */ -#define ACPI_DEBUG_PRINT(pl) -#define ACPI_DEBUG_PRINT_RAW(pl) -#define ACPI_DEBUG_EXEC(a) -#define ACPI_DEBUG_ONLY_MEMBERS(a) -#define ACPI_FUNCTION_NAME(a) -#define ACPI_FUNCTION_TRACE(a) -#define ACPI_FUNCTION_TRACE_PTR(a, b) -#define ACPI_FUNCTION_TRACE_U32(a, b) -#define ACPI_FUNCTION_TRACE_STR(a, b) -#define ACPI_FUNCTION_ENTRY() -#define ACPI_DUMP_STACK_ENTRY(a) -#define ACPI_DUMP_OPERANDS(a, b, c) -#define ACPI_DUMP_ENTRY(a, b) -#define ACPI_DUMP_PATHNAME(a, b, c, d) -#define ACPI_DUMP_BUFFER(a, b) +#define ACPI_DEBUG_PRINT(pl) ACPI_DO_WHILE0({}) +#define ACPI_DEBUG_PRINT_RAW(pl) ACPI_DO_WHILE0({}) +#define ACPI_DEBUG_EXEC(a) ACPI_DO_WHILE0({}) +#define ACPI_DEBUG_ONLY_MEMBERS(a) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_NAME(a) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_TRACE(a) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_DO_WHILE0({}) +#define ACPI_FUNCTION_ENTRY() ACPI_DO_WHILE0({}) +#define ACPI_DUMP_STACK_ENTRY(a) ACPI_DO_WHILE0({}) +#define ACPI_DUMP_OPERANDS(a, b, c) ACPI_DO_WHILE0({}) +#define ACPI_DUMP_ENTRY(a, b) ACPI_DO_WHILE0({}) +#define ACPI_DUMP_PATHNAME(a, b, c, d) ACPI_DO_WHILE0({}) +#define ACPI_DUMP_BUFFER(a, b) ACPI_DO_WHILE0({}) #define ACPI_IS_DEBUG_ENABLED(level, component) 0 -#define ACPI_TRACE_POINT(a, b, c, d) +#define ACPI_TRACE_POINT(a, b, c, d) ACPI_DO_WHILE0({}) /* Return macros must have a return statement at the minimum */