[PATCH] drivers/pcwd_pci:Fix the wrong format specifier

Zhu Jun posted 1 patch 1 month, 2 weeks ago
drivers/watchdog/pcwd_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] drivers/pcwd_pci:Fix the wrong format specifier
Posted by Zhu Jun 1 month, 2 weeks ago
The format specifier of "int" in printf() should be "%d", not
"%u".

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/watchdog/pcwd_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
index a489b426f2ba..3672e7f23b39 100644
--- a/drivers/watchdog/pcwd_pci.c
+++ b/drivers/watchdog/pcwd_pci.c
@@ -230,7 +230,7 @@ static void pcipcwd_show_card_info(void)
 	got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major,
 								&fw_rev_minor);
 	if (got_fw_rev)
-		sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
+		sprintf(fw_ver_str, "%d.%02d", fw_rev_major, fw_rev_minor);
 	else
 		sprintf(fw_ver_str, "<card no answer>");
 
-- 
2.17.1
Re: [PATCH] drivers/pcwd_pci:Fix the wrong format specifier
Posted by Wim Van Sebroeck 3 weeks, 2 days ago
Hi Zhu,

> The format specifier of "int" in printf() should be "%d", not
> "%u".
> 
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
>  drivers/watchdog/pcwd_pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
> index a489b426f2ba..3672e7f23b39 100644
> --- a/drivers/watchdog/pcwd_pci.c
> +++ b/drivers/watchdog/pcwd_pci.c
> @@ -230,7 +230,7 @@ static void pcipcwd_show_card_info(void)
>  	got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major,
>  								&fw_rev_minor);
>  	if (got_fw_rev)
> -		sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
> +		sprintf(fw_ver_str, "%d.%02d", fw_rev_major, fw_rev_minor);
>  	else
>  		sprintf(fw_ver_str, "<card no answer>");
>  
> -- 
> 2.17.1

%d = The argument is treated as an integer and presented as a (signed) decimal number. 
%u = The argument is treated as an integer and presented as an unsigned decimal number.

I do hope that version number are unsigned...

Kind regards,
Wim.