2014-08-06 04:43:53

by Hans Wennborg

[permalink] [raw]
Subject: [PATCH 08/15] rtlwifi: rtl8192de: fix decimal printf format specifiers prefixed with 0x

The prefix suggests the number should be printed in hex, so use
the %x specifier to do that.

Found by using regex suggested by Joe Perches.

Signed-off-by: Hans Wennborg <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
index 2317707..66e1760 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
@@ -234,7 +234,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
rtl_read_byte(rtlpriv, FW_MAC1_READY));
}
RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
- "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n",
+ "Polling FW ready fail!! REG_MCUFWDL:0x%08lx\n",
rtl_read_dword(rtlpriv, REG_MCUFWDL));
return -1;
}
--
2.0.0.526.g5318336



2014-08-06 14:39:07

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 08/15] rtlwifi: rtl8192de: fix decimal printf format specifiers prefixed with 0x

On 08/05/2014 11:43 PM, Hans Wennborg wrote:
> The prefix suggests the number should be printed in hex, so use
> the %x specifier to do that.
>
> Found by using regex suggested by Joe Perches.
>
> Signed-off-by: Hans Wennborg <[email protected]>
> ---
> drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> index 2317707..66e1760 100644
> --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> @@ -234,7 +234,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
> rtl_read_byte(rtlpriv, FW_MAC1_READY));
> }
> RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
> - "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n",
> + "Polling FW ready fail!! REG_MCUFWDL:0x%08lx\n",
> rtl_read_dword(rtlpriv, REG_MCUFWDL));
> return -1;
> }

It would be best to actually build with your patches installed. This one yields
the following warning:

CC [M] drivers/net/wireless/rtlwifi/rtl8192de/fw.o
drivers/net/wireless/rtlwifi/rtl8192de/fw.c: In function ?_rtl92d_fw_init?:
drivers/net/wireless/rtlwifi/rtl8192de/fw.c:236:2: warning: format ?%lx? expects
argument of type ?long unsigned int?, but argument 5 has type ?u32? [-Wformat=]
RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
^

The format specifier should be %04x, not %08lx. I have no idea why gcc did not
complain as %08ul is also wrong.

Larry


2014-08-07 05:25:10

by Hans Wennborg

[permalink] [raw]
Subject: Re: [PATCH 08/15] rtlwifi: rtl8192de: fix decimal printf format specifiers prefixed with 0x

On 08/06/2014 07:38 AM, Larry Finger wrote:
> On 08/05/2014 11:43 PM, Hans Wennborg wrote:
>> The prefix suggests the number should be printed in hex, so use
>> the %x specifier to do that.
>>
>> Found by using regex suggested by Joe Perches.
>>
>> Signed-off-by: Hans Wennborg <[email protected]>
>> ---
>> drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
>> index 2317707..66e1760 100644
>> --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
>> +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
>> @@ -234,7 +234,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
>> rtl_read_byte(rtlpriv, FW_MAC1_READY));
>> }
>> RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
>> - "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n",
>> + "Polling FW ready fail!! REG_MCUFWDL:0x%08lx\n",
>> rtl_read_dword(rtlpriv, REG_MCUFWDL));
>> return -1;
>> }
>
> It would be best to actually build with your patches installed. This one yields
> the following warning:

Terribly sorry about that, and thanks for catching it. I naively assumed
that the code was correct besides the decimal vs. hex issue.

> CC [M] drivers/net/wireless/rtlwifi/rtl8192de/fw.o
> drivers/net/wireless/rtlwifi/rtl8192de/fw.c: In function ?_rtl92d_fw_init?:
> drivers/net/wireless/rtlwifi/rtl8192de/fw.c:236:2: warning: format ?%lx? expects
> argument of type ?long unsigned int?, but argument 5 has type ?u32? [-Wformat=]
> RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
> ^
>
> The format specifier should be %04x, not %08lx.

Shouldn't it be %08x since it's a 32-bit value?

> I have no idea why gcc did not complain as %08ul is also wrong.

I assume the compiler would have warned about %08lu, but %08ul takes an
unsigned and just prints an l afterwards.

- Hans