[ofa-general] [PATCH] libibmad: eliminate compiler warnings on x86_64

Jack Morgenstein jackm at dev.mellanox.co.il
Wed Sep 24 06:59:19 PDT 2008


libibmad: eliminate compiler warnings on x86_64

The snprintf's below generated warnings of the form:
warning: format '%010lx' expects type 'long unsigned int', but argument 4 has type 'long long unsigned int'
on 64-bit systems -- due to the influence of the <>llu constants. Casting solves this.

Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>
---

Please fix for upcoming OFED 1.4 release candidate.

Index: libibmad/src/dump.c
===================================================================
--- libibmad.orig/src/dump.c	2008-09-24 09:20:04.000000000 +0300
+++ libibmad/src/dump.c	2008-09-24 09:22:00.000000000 +0300
@@ -115,13 +115,13 @@ mad_dump_hex(char *buf, int bufsz, void 
 		snprintf(buf, bufsz, "0x%08x", *(uint32_t *)val);
 		break;
 	case 5:
-		snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val & 0xffffffffffllu);
+		snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffllu);
 		break;
 	case 6:
-		snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val & 0xffffffffffffllu);
+		snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffllu);
 		break;
 	case 7:
-		snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val & 0xffffffffffffffllu);
+		snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffllu);
 		break;
 	case 8:
 		snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *)val);
@@ -149,13 +149,13 @@ mad_dump_rhex(char *buf, int bufsz, void
 		snprintf(buf, bufsz, "%08x", *(uint32_t *)val);
 		break;
 	case 5:
-		snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val & 0xffffffffffllu);
+		snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffllu);
 		break;
 	case 6:
-		snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val & 0xffffffffffffllu);
+		snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffllu);
 		break;
 	case 7:
-		snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val & 0xffffffffffffffllu);
+		snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffllu);
 		break;
 	case 8:
 		snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *)val);



More information about the general mailing list