Skip to contentSkip to conversation

peak_usb: fix clang build warning

PATCH Applied Arnd Bergmann 3 participants 4 messages Mar 7, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 peak_usb: fix clang build warning

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.

---
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -1
index d516def846ab..b388406ac0f5 100644
@@ -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;
Signature · 1 line
2.20.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Arnd Bergmann

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.

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

Quoted 20 lines
---
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +1 -1
index d516def846ab..b388406ac0f5 100644
@@ -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;
Signature · 1 line
2.20.0
#2 lore raw
Quoted 6 lines · Nathan Chancellor
Quoted 4 lines · Arnd Bergmann

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]

Quoted 7 lines
Quoted 4 lines

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

Thanks!

Quoted 2 lines

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

maintainer Applied
#3 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Thu, 7 Mar 2019 11:31:55 +0100

Quoted 8 lines

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.

Applied.