linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] peak_usb: fix clang build warning
@ 2019-03-07 10:31 Arnd Bergmann
  2019-03-07 15:31 ` Nathan Chancellor
  2019-03-07 17:40 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-03-07 10:31 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller
  Cc: Nick Desaulniers, Arnd Bergmann, Gustavo A. R. Silva, linux-can,
	netdev, linux-kernel

Clang points out undefined behavior when building the pcan_usb_pro driver:

drivers/net/can/usb/peak_usb/pcan_usb_pro.c:136:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]

Changing the function prototype to avoid argument promotion in the
varargs call avoids the warning, and should make this well-defined.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index d516def846ab..b388406ac0f5 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -127,7 +127,7 @@ static u8 *pcan_msg_init_empty(struct pcan_usb_pro_msg *pm,
 /*
  * add one record to a message being built
  */
-static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, u8 id, ...)
+static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...)
 {
 	int len, i;
 	u8 *pc;
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] peak_usb: fix clang build warning
  2019-03-07 10:31 [PATCH] peak_usb: fix clang build warning Arnd Bergmann
@ 2019-03-07 15:31 ` Nathan Chancellor
  2019-03-07 15:38   ` Arnd Bergmann
  2019-03-07 17:40 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2019-03-07 15:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Nick Desaulniers, Gustavo A. R. Silva, linux-can, netdev,
	linux-kernel

On Thu, Mar 07, 2019 at 11:31:55AM +0100, Arnd Bergmann wrote:
> Clang points out undefined behavior when building the pcan_usb_pro driver:
> 
> drivers/net/can/usb/peak_usb/pcan_usb_pro.c:136:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]
> 
> Changing the function prototype to avoid argument promotion in the
> varargs call avoids the warning, and should make this well-defined.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Link: https://github.com/ClangBuiltLinux/linux/issues/109
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

I wonder if the format specifier in the pr_err statement at the end of
this function should be updated.

> ---
>  drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
> index d516def846ab..b388406ac0f5 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
> @@ -127,7 +127,7 @@ static u8 *pcan_msg_init_empty(struct pcan_usb_pro_msg *pm,
>  /*
>   * add one record to a message being built
>   */
> -static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, u8 id, ...)
> +static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...)
>  {
>  	int len, i;
>  	u8 *pc;
> -- 
> 2.20.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] peak_usb: fix clang build warning
  2019-03-07 15:31 ` Nathan Chancellor
@ 2019-03-07 15:38   ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-03-07 15:38 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Nick Desaulniers, Gustavo A. R. Silva, linux-can, Networking,
	Linux Kernel Mailing List

On Thu, Mar 7, 2019 at 4:31 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Thu, Mar 07, 2019 at 11:31:55AM +0100, Arnd Bergmann wrote:
> > Clang points out undefined behavior when building the pcan_usb_pro driver:
> >
> > drivers/net/can/usb/peak_usb/pcan_usb_pro.c:136:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]
> >
> > Changing the function prototype to avoid argument promotion in the
> > varargs call avoids the warning, and should make this well-defined.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/109
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

Thanks!

> I wonder if the format specifier in the pr_err statement at the end of
> this function should be updated.

I think it's still ok as it is.

      Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] peak_usb: fix clang build warning
  2019-03-07 10:31 [PATCH] peak_usb: fix clang build warning Arnd Bergmann
  2019-03-07 15:31 ` Nathan Chancellor
@ 2019-03-07 17:40 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-07 17:40 UTC (permalink / raw)
  To: arnd; +Cc: wg, mkl, ndesaulniers, gustavo, linux-can, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Thu,  7 Mar 2019 11:31:55 +0100

> Clang points out undefined behavior when building the pcan_usb_pro driver:
> 
> drivers/net/can/usb/peak_usb/pcan_usb_pro.c:136:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]
> 
> Changing the function prototype to avoid argument promotion in the
> varargs call avoids the warning, and should make this well-defined.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-07 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:31 [PATCH] peak_usb: fix clang build warning Arnd Bergmann
2019-03-07 15:31 ` Nathan Chancellor
2019-03-07 15:38   ` Arnd Bergmann
2019-03-07 17:40 ` David Miller

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).