* [PATCH] bridge: Fix format string for %ul
@ 2016-08-27 3:10 Oleg Drokin
2016-08-27 15:13 ` Sergei Shtylyov
2017-10-03 20:43 ` Stephen Hemminger
0 siblings, 2 replies; 6+ messages in thread
From: Oleg Drokin @ 2016-08-27 3:10 UTC (permalink / raw)
To: Stephen Hemminger, David S. Miller
Cc: bridge, netdev, linux-kernel, Oleg Drokin
%ul would print an unsigned value and a letter l,
likely it was %lu that was meant to print the long int,
but in reality the values printed there are just regular signed
ints, so just dropping the l altogether.
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
net/bridge/br_stp_bpdu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 5881fbc..15c4a9c 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -230,7 +230,7 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
if (net_ratelimit())
br_notice(p->br,
"port %u config from %pM"
- " (message_age %ul > max_age %ul)\n",
+ " (message_age %u > max_age %u)\n",
p->port_no,
eth_hdr(skb)->h_source,
bpdu.message_age, bpdu.max_age);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] bridge: Fix format string for %ul
2016-08-27 3:10 [PATCH] bridge: Fix format string for %ul Oleg Drokin
@ 2016-08-27 15:13 ` Sergei Shtylyov
2016-08-27 15:58 ` Oleg Drokin
2017-10-03 20:43 ` Stephen Hemminger
1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2016-08-27 15:13 UTC (permalink / raw)
To: Oleg Drokin, Stephen Hemminger, David S. Miller
Cc: netdev, bridge, linux-kernel
Hello.
On 8/27/2016 6:10 AM, Oleg Drokin wrote:
> %ul would print an unsigned value and a letter l,
> likely it was %lu that was meant to print the long int,
> but in reality the values printed there are just regular signed
Signed? Then you need probably "%d" or "%i"...
> ints, so just dropping the l altogether.
>
> Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bridge: Fix format string for %ul
2016-08-27 15:13 ` Sergei Shtylyov
@ 2016-08-27 15:58 ` Oleg Drokin
2016-08-27 16:18 ` Sergei Shtylyov
0 siblings, 1 reply; 6+ messages in thread
From: Oleg Drokin @ 2016-08-27 15:58 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Stephen Hemminger, David S. Miller, bridge, netdev, linux-kernel
On Aug 27, 2016, at 11:13 AM, Sergei Shtylyov wrote:
> Hello.
>
> On 8/27/2016 6:10 AM, Oleg Drokin wrote:
>
>> %ul would print an unsigned value and a letter l,
>> likely it was %lu that was meant to print the long int,
>> but in reality the values printed there are just regular signed
>
> Signed? Then you need probably "%d" or "%i"…
They are signed in the struct definition, but in reality they
designate time, so could not be negative, I imagine?
>
>> ints, so just dropping the l altogether.
>>
>> Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
> [...]
>
> MBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bridge: Fix format string for %ul
2016-08-27 15:58 ` Oleg Drokin
@ 2016-08-27 16:18 ` Sergei Shtylyov
2016-08-27 16:36 ` Oleg Drokin
0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2016-08-27 16:18 UTC (permalink / raw)
To: Oleg Drokin; +Cc: netdev, bridge, David S. Miller, linux-kernel
Hello.
On 8/27/2016 6:58 PM, Oleg Drokin wrote:
>>> %ul would print an unsigned value and a letter l,
>>> likely it was %lu that was meant to print the long int,
>>> but in reality the values printed there are just regular signed
>>
>> Signed? Then you need probably "%d" or "%i"…
>
> They are signed in the struct definition, but in reality they
> designate time, so could not be negative, I imagine?
That doesn't matter. If the type is signed, it should be printed as signed.
Doesn't gcc complain about the format specifiers not matching the values passed?
>>> ints, so just dropping the l altogether.
>>>
>>> Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
>> [...]
MBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bridge: Fix format string for %ul
2016-08-27 16:18 ` Sergei Shtylyov
@ 2016-08-27 16:36 ` Oleg Drokin
0 siblings, 0 replies; 6+ messages in thread
From: Oleg Drokin @ 2016-08-27 16:36 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Stephen Hemminger, David S. Miller, bridge, netdev, linux-kernel
On Aug 27, 2016, at 12:18 PM, Sergei Shtylyov wrote:
> Hello.
>
> On 8/27/2016 6:58 PM, Oleg Drokin wrote:
>
>>>> %ul would print an unsigned value and a letter l,
>>>> likely it was %lu that was meant to print the long int,
>>>> but in reality the values printed there are just regular signed
>>>
>>> Signed? Then you need probably "%d" or "%i"…
>>
>> They are signed in the struct definition, but in reality they
>> designate time, so could not be negative, I imagine?
>
> That doesn't matter. If the type is signed, it should be printed as signed.
> Doesn't gcc complain about the format specifiers not matching the values passed?
only if the size differs.
I don't care either way.
I can change the struct to unsigned too, but if we want super correctness,
the problem lies deeper.
E.g. if we look how those times are derived, the age comes as:
static inline int br_get_ticks(const unsigned char *src)
{
unsigned long ticks = get_unaligned_be16(src);
return DIV_ROUND_UP(ticks * HZ, STP_HZ);
}
So we divide unsigned value by positive value and get a signed result ;)
there's a struct net_bridge_port with similar members in this are that are
unsigned long, so I guess we should convert to unsigned long in the
struct br_config_bpdu, do you want a patch for that separately or as part of this one?
>
>>>> ints, so just dropping the l altogether.
>>>>
>>>> Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
>>> [...]
>
> MBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bridge: Fix format string for %ul
2016-08-27 3:10 [PATCH] bridge: Fix format string for %ul Oleg Drokin
2016-08-27 15:13 ` Sergei Shtylyov
@ 2017-10-03 20:43 ` Stephen Hemminger
1 sibling, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2017-10-03 20:43 UTC (permalink / raw)
To: Oleg Drokin; +Cc: David S. Miller, bridge, netdev, linux-kernel
On Fri, 26 Aug 2016 23:10:28 -0400
Oleg Drokin <green@linuxhacker.ru> wrote:
> %ul would print an unsigned value and a letter l,
> likely it was %lu that was meant to print the long int,
> but in reality the values printed there are just regular signed
> ints, so just dropping the l altogether.
>
> Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
> ---
> net/bridge/br_stp_bpdu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
> index 5881fbc..15c4a9c 100644
> --- a/net/bridge/br_stp_bpdu.c
> +++ b/net/bridge/br_stp_bpdu.c
> @@ -230,7 +230,7 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
> if (net_ratelimit())
> br_notice(p->br,
> "port %u config from %pM"
> - " (message_age %ul > max_age %ul)\n",
> + " (message_age %u > max_age %u)\n",
> p->port_no,
> eth_hdr(skb)->h_source,
> bpdu.message_age, bpdu.max_age);
Could you make the format string a single line plwase.
And add Fixes tag.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-03 20:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-27 3:10 [PATCH] bridge: Fix format string for %ul Oleg Drokin
2016-08-27 15:13 ` Sergei Shtylyov
2016-08-27 15:58 ` Oleg Drokin
2016-08-27 16:18 ` Sergei Shtylyov
2016-08-27 16:36 ` Oleg Drokin
2017-10-03 20:43 ` Stephen Hemminger
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).