Skip to contentSkip to conversation

nvme-cli: fix compilation with uint64_t cast

PATCH New Chaitanya Kulkarni 2 participants 2 messages Jan 25, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-cli: fix compilation with uint64_t cast

Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>

---
Following is the compilation error for reference.

[root at mercury nvme-cli]# make
cc -D_GNU_SOURCE -D__CHECK_ENDIAN__ -O2 -g -Wall -Werror -std=gnu99 -I. -DLIBUUID -DNVME_VERSION='"1.7.14.g37d4"' nvme.c -o nvme argconfig.o suffix.o parser.o nvme-print.o nvme-ioctl.o nvme-lightnvm.o fabrics.o json.o nvme-models.o plugin.o plugins/intel/intel-nvme.o plugins/lnvm/lnvm-nvme.o plugins/memblaze/memblaze-nvme.o plugins/wdc/wdc-nvme.o plugins/wdc/wdc-utils.o plugins/huawei/huawei-nvme.o plugins/netapp/netapp-nvme.o plugins/toshiba/toshiba-nvme.o plugins/micron/micron-nvme.o plugins/seagate/seagate-nvme.o -luuid nvme.c: In function ???format???:
nvme.c:3056:38: error: format ???%lu??? expects argument of type ???long unsigned int???, but argument 3 has type ???__u64 {aka long long unsigned int}??? [-Werror=format=]

     "Invalid value for block size (%lu), must be a power of two\n",
                                    ~~^
                                    %llu
      cfg.bs);
      ~~~~~~                           
nvme.c:3091:42: error: format ???%lu??? expects argument of type ???long unsigned int???, but argument 3 has type ???__u64 {aka long long unsigned int}??? [-Werror=format=]
      "LBAF corresponding to block size %lu (LBAF %u) not found\n",
                                        ~~^
                                        %llu
      cfg.bs, lbads);
      ~~~~~~                               

cc1: all warnings being treated as errors
make: *** [nvme] Error 1

Git tree HEAD for reference :-

$ git log -1 
commit 4f474f0f9c0704c538d5bbdb6f4a70f1373b7943
Merge: eb58f54 254bcd6
Author: Keith Busch <keith.busch at intel.com>
Date:   Tue Jan 22 09:27:09 2019 -0700

Merge pull request #451 from leitao/master

Fix building issues

---
 nvme.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
nvme.c +4 -4
index e85834d..8922ec2 100644
@@ -3053,8 +3053,8 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu
 	if (cfg.bs) {
 		if ((cfg.bs & (~cfg.bs + 1)) != cfg.bs) {
 			fprintf(stderr,
-				"Invalid value for block size (%lu), must be a power of two\n",
-					cfg.bs);
+				"Invalid value for block size (%"PRIu64"), must be a power of two\n",
+				       (uint64_t) cfg.bs);
 				return EINVAL;
 		}
 	}
@@ -3088,8 +3088,8 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu
 			}
 			if (cfg.lbaf == 0xff) {
 				fprintf(stderr,
-					"LBAF corresponding to block size %lu (LBAF %u) not found\n",
-					cfg.bs, lbads);
+					"LBAF corresponding to block size %"PRIu64"(LBAF %u) not found\n",
+					(uint64_t)cfg.bs, lbads);
 				fprintf(stderr,
 					"Please correct block size, or specify LBAF directly\n");
 				return EINVAL;
Signature · 1 line
2.14.1
Applied
#1 lore raw

PATCH 1/1 nvme-cli: fix compilation with uint64_t cast

Quoted 1 line · Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>

Thanks, applied.