]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Fix cast to enable nvme to compile on 64-bits architecture
authorBreno Leitao <breno.leitao@gmail.com>
Mon, 11 Jul 2016 18:31:29 +0000 (14:31 -0400)
committerBreno Leitao <breno.leitao@gmail.com>
Mon, 11 Jul 2016 18:31:29 +0000 (14:31 -0400)
Currently, nvme-cli is enabled on all Debian and Ubuntu architectures,
which includes 64 and 32 bits architecture.

Version 0.8 does not compile in any 32 bits architecture, as it shows:

 cc -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -g -O2 -fPIE
 -fstack-protector-strong -Wformat -Werror=format-security -std=gnu99 -O2
 -g -Wall -Werror -DLIBUDEV_EXISTS -DNVME_VERSION='"0.8"' -c intel-nvme.c
 intel-nvme.c: In function ‘get_internal_log’:
 intel-nvme.c:310:13: error: cast from pointer to integer of different
 size [-Werror=pointer-to-int-cast]
   cmd.addr = (__u64)(void *)buf;
             ^
 cc1: all warnings being treated as errors

The cmd.addr field is defined as __u64 on all architectures, but a
pointer is not always 64-bit, making this an error.  Cast to 'unsigned
long' instead, which is safe on all supported architectures, and let the
compiler take it from there.

Patch created by Steve Langasek <steve.langasek@ubuntu.com>

intel-nvme.c

index 241b26cdae6c762f24cbfd8513d44a245ed062e6..6b9c6231762bcfa25e9ad9c3c238d5d521598795 100644 (file)
@@ -309,7 +309,7 @@ static int get_internal_log(int argc, char **argv, struct command *command, stru
        cmd.cdw10 = 0x400;
        cmd.cdw12 = cfg.log;
        cmd.data_len = 0x1000;
-       cmd.addr = (__u64)(void *)buf;
+       cmd.addr = (unsigned long)(void *)buf;
 
        memset(buf, 0, sizeof(buf));
        err = nvme_submit_passthru(fd, NVME_IOCTL_ADMIN_CMD, &cmd);