* [PATCH] gpio: aspeed: fix compile testing warning
@ 2018-07-09 14:56 Arnd Bergmann
2018-07-09 15:31 ` Alexander Stein
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Arnd Bergmann @ 2018-07-09 14:56 UTC (permalink / raw)
To: Linus Walleij, Joel Stanley
Cc: Arnd Bergmann, Andrew Jeffery, Benjamin Herrenschmidt,
Thierry Reding, linux-gpio, linux-arm-kernel, linux-aspeed,
linux-kernel
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 <arnd@arndb.de>
---
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)
--
2.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: aspeed: fix compile testing warning
2018-07-09 14:56 [PATCH] gpio: aspeed: fix compile testing warning Arnd Bergmann
@ 2018-07-09 15:31 ` Alexander Stein
2018-07-09 19:52 ` Arnd Bergmann
2018-07-09 23:53 ` Benjamin Herrenschmidt
2018-07-13 7:05 ` Linus Walleij
2 siblings, 1 reply; 6+ messages in thread
From: Alexander Stein @ 2018-07-09 15:31 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linus Walleij, Joel Stanley, Andrew Jeffery,
Benjamin Herrenschmidt, Thierry Reding, linux-gpio,
linux-arm-kernel, linux-aspeed, linux-kernel
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 <arnd@arndb.de>
> ---
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: aspeed: fix compile testing warning
2018-07-09 15:31 ` Alexander Stein
@ 2018-07-09 19:52 ` Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2018-07-09 19:52 UTC (permalink / raw)
To: Alexander Stein
Cc: Linus Walleij, Joel Stanley, Andrew Jeffery,
Benjamin Herrenschmidt, Thierry Reding, linux-gpio, Linux ARM,
linux-aspeed, Linux Kernel Mailing List
On Mon, Jul 9, 2018 at 5:31 PM, Alexander Stein
<alexander.stein@systec-electronic.com> wrote:
> 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 <arnd@arndb.de>
>> ---
>> 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?
On most architectures and configurations yes, but not on some of
the minor architectures if CONFIG_BUG is disabled.
> 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.
Not sure, that might not work well in cases where it's a compile-time
constant in some configurations but variable in others.
> 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.
Right.
Traditionally when CONFIG_BUG was disabled, we would have continued
here, so that could have been intentional, but in any case a WARN_ON()
would have been more appropriate here.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: aspeed: fix compile testing warning
2018-07-09 14:56 [PATCH] gpio: aspeed: fix compile testing warning Arnd Bergmann
2018-07-09 15:31 ` Alexander Stein
@ 2018-07-09 23:53 ` Benjamin Herrenschmidt
2018-07-13 7:06 ` Linus Walleij
2018-07-13 7:05 ` Linus Walleij
2 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2018-07-09 23:53 UTC (permalink / raw)
To: Arnd Bergmann, Linus Walleij, Joel Stanley
Cc: Andrew Jeffery, Thierry Reding, linux-gpio, linux-arm-kernel,
linux-aspeed, linux-kernel
On Mon, 2018-07-09 at 16:56 +0200, 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 <arnd@arndb.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Linus, can you plonk that on top of the patches in that topic branch
you created ?
> ---
> 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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: aspeed: fix compile testing warning
2018-07-09 14:56 [PATCH] gpio: aspeed: fix compile testing warning Arnd Bergmann
2018-07-09 15:31 ` Alexander Stein
2018-07-09 23:53 ` Benjamin Herrenschmidt
@ 2018-07-13 7:05 ` Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2018-07-13 7:05 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Joel Stanley, Andrew Jeffery, Benjamin Herrenschmidt,
Thierry Reding, open list:GPIO SUBSYSTEM, Linux ARM,
linux-aspeed, linux-kernel
On Mon, Jul 9, 2018 at 4:56 PM Arnd Bergmann <arnd@arndb.de> 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 <arnd@arndb.de>
Patch applied with Benjamin's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: aspeed: fix compile testing warning
2018-07-09 23:53 ` Benjamin Herrenschmidt
@ 2018-07-13 7:06 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2018-07-13 7:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Arnd Bergmann, Joel Stanley, Andrew Jeffery, Thierry Reding,
open list:GPIO SUBSYSTEM, Linux ARM, linux-aspeed, linux-kernel
On Tue, Jul 10, 2018 at 1:53 AM Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Mon, 2018-07-09 at 16:56 +0200, 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 <arnd@arndb.de>
>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> Linus, can you plonk that on top of the patches in that topic branch
> you created ?
I put it on top of my devel branch where I merged in the topic
branch.
As it's a fringe thing anyways I don't think we need to recreate the
topic branch for this.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-13 7:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-09 14:56 [PATCH] gpio: aspeed: fix compile testing warning Arnd Bergmann
2018-07-09 15:31 ` Alexander Stein
2018-07-09 19:52 ` Arnd Bergmann
2018-07-09 23:53 ` Benjamin Herrenschmidt
2018-07-13 7:06 ` Linus Walleij
2018-07-13 7:05 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).