peak_usb: fix clang build warning
Subsystems (3)
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
@@ -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
Quoted 8 lines · Arnd Bergmann
Clang points out undefined behavior when building the
pcan_usb_prodriver:
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 <[email protected]>
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@@ -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
Quoted 6 lines · Nathan Chancellor
Quoted 4 lines · Arnd Bergmann
Clang points out undefined behavior when building the
pcan_usb_prodriver:
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.
Signed-off-by Arnd Bergmann <[email protected]>
Thanks!
Quoted 2 lines
I wonder if the format specifier in the
pr_errstatement at the end of this function should be updated.
I think it's still ok as it is.
Arnd
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_prodriver:
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 <[email protected]>
Applied.