[10/11] batman-adv: print OGM seq numbers as unsigned long
Commit Message
OGM sequence numbers are declared as uint32_t and so they have to printed
using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
net/batman-adv/bat_iv_ogm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
From: Antonio Quartulli <ordex@autistici.org>
Date: Tue, 17 Apr 2012 13:58:26 +0200
> OGM sequence numbers are declared as uint32_t and so they have to printed
> using %u instead of %d in order to avoid wrong representations.
>
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Fix this commit message subject, "%u" is "unsigned int" not
"unsigned long"
"unsigned long" would be "%lu"
On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
> From: Antonio Quartulli <ordex@autistici.org>
> Date: Tue, 17 Apr 2012 13:58:26 +0200
>
> > OGM sequence numbers are declared as uint32_t and so they have to printed
> > using %u instead of %d in order to avoid wrong representations.
> >
> > Signed-off-by: Antonio Quartulli <ordex@autistici.org>
>
> Fix this commit message subject, "%u" is "unsigned int" not
> "unsigned long"
>
> "unsigned long" would be "%lu"
Yap. The broken part is %u, because the data type we are going to print is
uint32_t. I'll fix it.
Thank you.
I'll send a new pull request once I'll have fixed these errors.
Cheers,
On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
> On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
> > From: Antonio Quartulli <ordex@autistici.org>
> > Date: Tue, 17 Apr 2012 13:58:26 +0200
> >
> > > OGM sequence numbers are declared as uint32_t and so they have to printed
> > > using %u instead of %d in order to avoid wrong representations.
> > >
> > > Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> >
> > Fix this commit message subject, "%u" is "unsigned int" not
> > "unsigned long"
> >
> > "unsigned long" would be "%lu"
There is a problem here. On my machine (x86_64) I have:
typedef unsigned int __u32;
typedef __u32 uint32_t;
So I should use %u to print my uint32_t variable (as I reported in my commit
message).
Probably this is not the case on each and every architecture?
If so, how could I handle it?
Cheers,
On Wed, Apr 18, 2012 at 09:01:35AM +0200, Antonio Quartulli wrote:
> On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
> > On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
> > > From: Antonio Quartulli <ordex@autistici.org>
> > > Date: Tue, 17 Apr 2012 13:58:26 +0200
> > >
> > > > OGM sequence numbers are declared as uint32_t and so they have to printed
> > > > using %u instead of %d in order to avoid wrong representations.
> > > >
> > > > Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> > >
> > > Fix this commit message subject, "%u" is "unsigned int" not
> > > "unsigned long"
> > >
> > > "unsigned long" would be "%lu"
>
> There is a problem here. On my machine (x86_64) I have:
>
> typedef unsigned int __u32;
> typedef __u32 uint32_t;
>
>
> So I should use %u to print my uint32_t variable (as I reported in my commit
> message).
>
> Probably this is not the case on each and every architecture?
> If so, how could I handle it?
Ok. After digging in the code again I understood that the problem is either in
my brain and in the commit subject.
I'll fix both.
Cheers,
From: Antonio Quartulli <ordex@autistici.org>
Date: Wed, 18 Apr 2012 09:01:35 +0200
> On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
>> On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
>> > From: Antonio Quartulli <ordex@autistici.org>
>> > Date: Tue, 17 Apr 2012 13:58:26 +0200
>> >
>> > > OGM sequence numbers are declared as uint32_t and so they have to printed
>> > > using %u instead of %d in order to avoid wrong representations.
>> > >
>> > > Signed-off-by: Antonio Quartulli <ordex@autistici.org>
>> >
>> > Fix this commit message subject, "%u" is "unsigned int" not
>> > "unsigned long"
>> >
>> > "unsigned long" would be "%lu"
>
> There is a problem here. On my machine (x86_64) I have:
>
> typedef unsigned int __u32;
> typedef __u32 uint32_t;
>
>
> So I should use %u to print my uint32_t variable (as I reported in my commit
> message).
>
> Probably this is not the case on each and every architecture?
> If so, how could I handle it?
The problem is not the patch, it's your commit message
you say "print ... as unsigned long", you're not printing
it as unsigned long, you're printing it as unsigned int.
@@ -152,7 +152,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
"Sending own" :
"Forwarding"));
bat_dbg(DBG_BATMAN, bat_priv,
- "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
+ "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_ogm_packet->orig,
ntohl(batman_ogm_packet->seqno),
@@ -211,7 +211,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
/* FIXME: what about aggregated packets ? */
bat_dbg(DBG_BATMAN, bat_priv,
- "%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%pM]\n",
+ "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
(forw_packet->own ? "Sending own" : "Forwarding"),
batman_ogm_packet->orig,
ntohl(batman_ogm_packet->seqno),
@@ -892,7 +892,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
if (need_update) {
bat_dbg(DBG_BATMAN, bat_priv,
- "updating last_seqno: old %d, new %d\n",
+ "updating last_seqno: old %u, new %u\n",
orig_node->last_real_seqno, batman_ogm_packet->seqno);
orig_node->last_real_seqno = batman_ogm_packet->seqno;
}
@@ -945,7 +945,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
batman_ogm_packet->orig) ? 1 : 0);
bat_dbg(DBG_BATMAN, bat_priv,
- "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
+ "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
ethhdr->h_source, if_incoming->net_dev->name,
if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,