Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp668342imm; Mon, 9 Jul 2018 08:32:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeiZfpz19D/DoytjEOtA3M7xQl7keguHXLNwoik/ezxlF+QX3Rn+6X5QjUAEjpN66yfSbT/ X-Received: by 2002:a62:e0d5:: with SMTP id d82-v6mr21721744pfm.59.1531150350957; Mon, 09 Jul 2018 08:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531150350; cv=none; d=google.com; s=arc-20160816; b=QOacC4qsC9YDO0GT9GmnmbTBdV3eI6h87FjhhoIoyvpFiuzvdlbueAiGaOiE1MTUwr kj8zW9v0IDiFalSRlO04yly+E07Z9GodCHxfvHaS9mj98l6lGcI+j19a0uJdrvZPxzO+ Z/MR/J1F6VBs0StFaA5hOJt417sC7A0nEzd2gEA4w5YXufXhBrPs+1vIPvNwtjBMqH6e 236TLGs+jt/gVAJYdn7R32UIsDOMxwSzxcC2g/9cwcxyzm3T1v8+/0J7veXjVvcp3p5g 1hYiNKzQR5bTvBUlIjwPubQD7TEEW8akxvAK1JQsxYALXK+vKks3UrKDD0K09iMztyk5 WZiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SjaEwuFNk0t7YeMIv3cR+pIt4l+lqI3KX0cNQ+3Yh4I=; b=sVmOryLGw/2CfRVYXQ9GSfh7QK1wjgVh5feyn4FVi0VkzH3Hp0Qg5BjQ/XgjSJoeY2 bIWWdwCrox8TY+h7578Q0FjnzHnEM9mJX0KOqG6VtvYjNocNESbGJp8hv+NsaaJvMtht pDJ+n+nxex4VyW7It3cb05G/BbOagERpqa9GazMAR/UbvfpV2F510WRHg4zWDmq1NxFy x+ujgKqd20gqTVp661TvW8LLrNEa+o9kHSiVmrYzGsSZ8T8AfkMUOxG3VwYU0DKs0KGn b7Bof54XQA0Ps4vJPvDfEY14oDsEpT0LX1zJ36pFNYtgvRBnk2GVeS5tdQ+4itMM7czF MA0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si15097303plb.381.2018.07.09.08.32.16; Mon, 09 Jul 2018 08:32:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933399AbeGIPb3 (ORCPT + 99 others); Mon, 9 Jul 2018 11:31:29 -0400 Received: from webbox1416.server-home.net ([77.236.96.61]:33562 "EHLO webbox1416.server-home.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933298AbeGIPb1 (ORCPT ); Mon, 9 Jul 2018 11:31:27 -0400 Received: from imapserver.systec-electronic.com (unknown [212.185.67.146]) by webbox1416.server-home.net (Postfix) with ESMTPA id A74A127A64E; Mon, 9 Jul 2018 17:31:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 72E761A7929; Mon, 9 Jul 2018 17:31:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at imapserver.systec-electronic.com Received: from imapserver.systec-electronic.com ([127.0.0.1]) by localhost (imapserver.systec-electronic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RXwySRVDCtJN; Mon, 9 Jul 2018 17:31:24 +0200 (CEST) Received: from ws-140106.localnet (ws-140106.systec.local [192.168.10.92]) by imapserver.systec-electronic.com (Postfix) with ESMTPA id A096B1A7928; Mon, 9 Jul 2018 17:31:24 +0200 (CEST) From: Alexander Stein To: Arnd Bergmann Cc: Linus Walleij , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Thierry Reding , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpio: aspeed: fix compile testing warning Date: Mon, 09 Jul 2018 17:31:24 +0200 Message-ID: <3652696.6JvIze6Ubc@ws-140106> In-Reply-To: <20180709145612.4166409-1-arnd@arndb.de> References: <20180709145612.4166409-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, July 9, 2018, 4:56:03 PM CEST Arnd Bergmann wrote: > Gcc cannot always see that BUG_ON(1) is guaranteed to not > return, so we get a warning message in some configurations: > > drivers/gpio/gpio-aspeed.c: In function 'bank_reg': > drivers/gpio/gpio-aspeed.c:244:1: error: control reaches end of non-void > function [-Werror=return-type] > > Using a plain BUG() is easier here and avoids the problem. > > Fixes: 44ddf559d579 ("gpio: aspeed: Rework register type accessors") > Signed-off-by: Arnd Bergmann > --- > drivers/gpio/gpio-aspeed.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c > index 1e00f4045f9d..2342e154029b 100644 > --- a/drivers/gpio/gpio-aspeed.c > +++ b/drivers/gpio/gpio-aspeed.c > @@ -240,7 +240,7 @@ static inline void __iomem *bank_reg(struct aspeed_gpio > *gpio, case reg_cmdsrc1: > return gpio->base + bank->cmdsrc_regs + GPIO_CMDSRC_1; > } > - BUG_ON(1); > + BUG(); > } > > #define GPIO_BANK(x) ((x) >> 5) Is the semantic of BUG() (and BUG_ON as well) to never return? If so, then just an idea: Is it possible to add some macro magic in BUG_ON(x) to fail compiling if x is compile-constant? Giving a hint the passed condition always fails, which indicates a problem, at least to me. From a short search I found this in drivers/gpu/vga/vgaarb.c L630-633: > if (vgadev_find(pdev) != NULL) { > BUG_ON(1); > goto fail; > } You can't fail with a BUG_ON(1) and try to do some error handling after that. Best regards, Alexander