Patchwork [Open-FCoE] fcoemon: Fix compilation error due to wrong print format

login
register
mail settings
Submitter Robert Love
Date June 27, 2013, 5:57 p.m.
Message ID <20130627175719.18450.18116.stgit@fritz>
Download mbox | patch
Permalink /patch/70/
State Accepted
Headers show

Comments

Robert Love - June 27, 2013, 5:57 p.m.
Use "%uz" to print a size_t type, which resolves the following warning/error.

cc1: warnings being treated as errors
fcoemon.c: In function ‘fcm_fc_event_recv’:
fcoemon.c:856:4: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’
make: *** [fcoemon-fcoemon.o] Error 1

Signed-off-by: Robert Love <robert.w.love@intel.com>
---
 fcoemon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Robert Love - June 27, 2013, 6:04 p.m.
> From: fcoe-devel-bounces@open-fcoe.org [mailto:fcoe-devel-

> bounces@open-fcoe.org] On Behalf Of Robert Love

> Sent: Thursday, June 27, 2013 10:57 AM

> To: fcoe-devel@open-fcoe.org

> Subject: [Open-FCoE] [PATCH] fcoemon: Fix compilation error due to wrong

> print format

> 

> Use "%uz" to print a size_t type, which resolves the following warning/error.

> 

> cc1: warnings being treated as errors

> fcoemon.c: In function ‘fcm_fc_event_recv’:

> fcoemon.c:856:4: error: format ‘%d’ expects type ‘int’, but argument 2 has

> type ‘size_t’

> make: *** [fcoemon-fcoemon.o] Error 1

> 

> Signed-off-by: Robert Love <robert.w.love@intel.com>


FYI, this fixes a problem that arises when I add Mark's stricter-compilation-flags patches.

I hurried this patch into fcoe-utils.git so that I could commit the rest of his patches.

Thanks, //Rob

Patch

diff --git a/fcoemon.c b/fcoemon.c
index 45a7645..87f4e26 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -817,7 +817,7 @@  static void fcm_fc_event_recv(UNUSED void *arg)
 	struct nlmsghdr *hp;
 	struct fc_nl_event *fc_event;
 	int plen;
-	int rlen;
+	size_t rlen;
 	char *buf;
 
 	buf = malloc(DEF_RX_BUF_SIZE);
@@ -851,7 +851,7 @@  static void fcm_fc_event_recv(UNUSED void *arg)
 		plen = NLMSG_PAYLOAD(hp, 0);
 		fc_event = (struct fc_nl_event *)NLMSG_DATA(hp);
 		if (plen < sizeof(*fc_event)) {
-			FCM_LOG("too short (%d) to be an FC event", rlen);
+			FCM_LOG("too short (%zu) to be an FC event", rlen);
 			break;
 		}
 		fcm_fc_event_log(fc_event);