[2/2] batctl: tcpdump - use proper format string when printing help message

Message ID 1460626198-31226-2-git-send-email-a@unstable.cc (mailing list archive)
State Rejected, archived
Delegated to: Marek Lindner
Headers

Commit Message

Antonio Quartulli April 14, 2016, 9:29 a.m. UTC
  this patch fixes warning like this

tcpdump.c:86:18: warning: format ‘%d’ expects argument of type ‘int’, but
argument 3 has type ‘long unsigned int’ [-Wformat=]

when comiling with gcc-5.3

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 tcpdump.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
  

Comments

Marek Lindner May 2, 2016, 2:04 p.m. UTC | #1
On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:
> +       fprintf(stderr, " \t\t%3lu - batman ogm packets\n",
> DUMP_TYPE_BATOGM); +       fprintf(stderr, " \t\t%3lu - batman ogmv2
> packets\n", DUMP_TYPE_BATOGM2); +       fprintf(stderr, " \t\t%3lu - batman
> elp packets\n", DUMP_TYPE_BATELP); +       fprintf(stderr, " \t\t%3lu -
> batman icmp packets\n", DUMP_TYPE_BATICMP); +       fprintf(stderr, "
> \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
> +       fprintf(stderr, " \t\t%3lu - batman broadcast packets\n",
> DUMP_TYPE_BATBCAST); +       fprintf(stderr, " \t\t%3lu - batman fragmented
> packets\n", DUMP_TYPE_BATFRAG); +       fprintf(stderr, " \t\t%3lu - batman
> unicast tvlv packets\n", DUMP_TYPE_BATUTVLV); +       fprintf(stderr, "
> \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
> +       fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n",
> DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);

$ make
    CC tcpdump.o
tcpdump.c: In function ‘tcpdump_usage’:
tcpdump.c:86:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogm packets\n", DUMP_TYPE_BATOGM);
                  ^
tcpdump.c:87:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
                  ^
tcpdump.c:88:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman elp packets\n", DUMP_TYPE_BATELP);
                  ^
tcpdump.c:89:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman icmp packets\n", DUMP_TYPE_BATICMP);
                  ^
tcpdump.c:90:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
                  ^
tcpdump.c:91:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman broadcast packets\n", 
DUMP_TYPE_BATBCAST);
                  ^
tcpdump.c:92:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman fragmented packets\n", 
DUMP_TYPE_BATFRAG);
                  ^
tcpdump.c:93:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman unicast tvlv packets\n", 
DUMP_TYPE_BATUTVLV);
                  ^
tcpdump.c:94:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
                  ^
tcpdump.c:95:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n", 
DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
                  ^

Cheers,
Marek
  
Antonio Quartulli May 2, 2016, 2:10 p.m. UTC | #2
On Mon, May 02, 2016 at 10:04:13PM +0800, Marek Lindner wrote:
> On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:

[..]

as explained in the original commit, I was getting the "opposite" warning. Now I
don't get it anymore. Not sure why.

I'd just suggest to drop the patch.

Cheers,
  
Sven Eckelmann May 2, 2016, 2:39 p.m. UTC | #3
On Monday 02 May 2016 22:10:41 Antonio Quartulli wrote:
> On Mon, May 02, 2016 at 10:04:13PM +0800, Marek Lindner wrote:
> > On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:
> 
> [..]
> 
> as explained in the original commit, I was getting the "opposite" warning. Now I
> don't get it anymore. Not sure why.
> 
> I'd just suggest to drop the patch.

You most likely had a different patch which used BIT(x) for DUMP_TYPE_* [1].

Kind regards,
	Sven

[1] https://patchwork.open-mesh.org/patch/4084/
  

Patch

diff --git a/tcpdump.c b/tcpdump.c
index 745f5d4..a036b93 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -83,16 +83,16 @@  static void tcpdump_usage(void)
 	fprintf(stderr, " \t -p dump specific packet type\n");
 	fprintf(stderr, " \t -x dump all packet types except specified\n");
 	fprintf(stderr, "packet types:\n");
-	fprintf(stderr, " \t\t%3d - batman ogm packets\n", DUMP_TYPE_BATOGM);
-	fprintf(stderr, " \t\t%3d - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
-	fprintf(stderr, " \t\t%3d - batman elp packets\n", DUMP_TYPE_BATELP);
-	fprintf(stderr, " \t\t%3d - batman icmp packets\n", DUMP_TYPE_BATICMP);
-	fprintf(stderr, " \t\t%3d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
-	fprintf(stderr, " \t\t%3d - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
-	fprintf(stderr, " \t\t%3d - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
-	fprintf(stderr, " \t\t%3d - batman unicast tvlv packets\n", DUMP_TYPE_BATUTVLV);
-	fprintf(stderr, " \t\t%3d - non batman packets\n", DUMP_TYPE_NONBAT);
-	fprintf(stderr, " \t\t%3d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
+	fprintf(stderr, " \t\t%3lu - batman ogm packets\n", DUMP_TYPE_BATOGM);
+	fprintf(stderr, " \t\t%3lu - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
+	fprintf(stderr, " \t\t%3lu - batman elp packets\n", DUMP_TYPE_BATELP);
+	fprintf(stderr, " \t\t%3lu - batman icmp packets\n", DUMP_TYPE_BATICMP);
+	fprintf(stderr, " \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
+	fprintf(stderr, " \t\t%3lu - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
+	fprintf(stderr, " \t\t%3lu - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
+	fprintf(stderr, " \t\t%3lu - batman unicast tvlv packets\n", DUMP_TYPE_BATUTVLV);
+	fprintf(stderr, " \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
+	fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
 }
 
 static int print_time(void)