[PATCH ibdiags 10/16] ibdiags: Use PRIx64 when printing uint64_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>

Fixes compiler warnings on 32 bit builds:

ibportstate.c:514:13: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 src/ibportstate.c   | 34 ++++++++++++++++++++++------------
 src/ibqueryerrors.c |  7 ++++---
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/ibportstate.c b/src/ibportstate.c
index 23f1ed5b7df07f..680c7e78f95a7a 100644
--- a/src/ibportstate.c
+++ b/src/ibportstate.c
@@ -459,40 +459,48 @@ int main(int argc, char **argv)
 			switch (j) {
 			case SPEED:
 				if (val > 15)
-					IBEXIT("invalid speed value %ld", val);
+					IBEXIT("invalid speed value %" PRIu64,
+					       val);
 				break;
 			case ESPEED:
 				if (val > 31)
-					IBEXIT("invalid extended speed value %ld", val);
+					IBEXIT("invalid extended speed value %" PRIu64,
+					       val);
 				break;
 			case FDR10SPEED:
 				if (val > 1)
-					IBEXIT("invalid fdr10 speed value %ld", val);
+					IBEXIT("invalid fdr10 speed value %" PRIu64,
+					       val);
 				break;
 			case WIDTH:
 				if ((val > 31 && val != 255))
-					IBEXIT("invalid width value %ld", val);
+					IBEXIT("invalid width value %" PRIu64,
+					       val);
 				break;
 			case VLS:
 				if (val == 0 || val > 5)
-					IBEXIT("invalid vls value %ld", val);
+					IBEXIT("invalid vls value %" PRIu64,
+					       val);
 				break;
 			case MTU:
 				if (val == 0 || val > 5)
-					IBEXIT("invalid mtu value %ld", val);
+					IBEXIT("invalid mtu value %" PRIu64,
+					       val);
 				break;
 			case LID:
 				if (val == 0 || val >= 0xC000)
-					IBEXIT("invalid lid value 0x%lx", val);
+					IBEXIT("invalid lid value 0x%" PRIx64,
+					       val);
 				break;
 			case SMLID:
 				if (val == 0 || val >= 0xC000)
-					IBEXIT("invalid smlid value 0x%lx",
-						val);
+					IBEXIT("invalid smlid value 0x%" PRIx64,
+					       val);
 				break;
 			case LMC:
 				if (val > 7)
-					IBEXIT("invalid lmc value %ld", val);
+					IBEXIT("invalid lmc value %" PRIu64,
+					       val);
 				break;
 			case MKEY:
 				errno = 0;
@@ -509,11 +517,13 @@ int main(int argc, char **argv)
 				break;
 			case MKEYLEASE:
 				if (val > 0xFFFF)
-					IBEXIT("invalid mkey lease time %ld", val);
+					IBEXIT("invalid mkey lease time %" PRIu64,
+					       val);
 				break;
 			case MKEYPROT:
 				if (val > 3)
-					IBEXIT("invalid mkey protection bit setting %ld", val);
+					IBEXIT("invalid mkey protection bit setting %" PRIu64,
+					       val);
 			}
 			*port_args[j].val = val;
 			changed = 1;
diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index a9f738dbb30c62..6cd652670977b4 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -112,7 +112,7 @@ static void set_thres(char *name, uint64_t val)
 	for (f = IB_PC_EXT_ERR_SYM_F; f <= IB_PC_EXT_XMT_WAIT_F; f++) {
 		if (strcmp(name, mad_field_name(f)) == 0) {
 			mad_encode_field(thresholds, f, &val);
-			snprintf(tmp, 255, "[%s = %lu]", name, val);
+			snprintf(tmp, 255, "[%s = %" PRIu64 "]", name, val);
 			threshold_str = realloc(threshold_str,
 					strlen(threshold_str)+strlen(tmp)+1);
 			if (!threshold_str) {
@@ -407,8 +407,9 @@ static int check_threshold(uint8_t *pc, uint8_t *pce, uint32_t cap_mask2,
 		mad_decode_field(pce, ext_i, (void *)&val64);
 		if (exceeds_threshold(ext_i, val64)) {
 			unit = conv_cnt_human_readable(val64, &val, 0);
-			*n += snprintf(str + *n, size - *n, " [%s == %lu (%5.3f%s)]",
-					  mad_field_name(ext_i), val64, val, unit);
+			*n += snprintf(str + *n, size - *n,
+				       " [%s == %" PRIu64 " (%5.3f%s)]",
+				       mad_field_name(ext_i), val64, val, unit);
 			is_exceeds = 1;
 		}
 
-- 
2.21.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux