From: Keith Busch Date: Tue, 6 Dec 2016 15:37:52 +0000 (-0500) Subject: Fix 48-bit conversion for 32-bit arch X-Git-Tag: v1.1~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4b61d9b11bb92400d5309a45c6080dfe6417a5cf;p=users%2Fsagi%2Fnvme-cli.git Fix 48-bit conversion for 32-bit arch The cast to 'long' was the wrong type for 32-bit. Signed-off-by: Keith Busch --- diff --git a/memblaze-nvme.c b/memblaze-nvme.c index d89aee8d..b48a0e83 100644 --- a/memblaze-nvme.c +++ b/memblaze-nvme.c @@ -138,9 +138,9 @@ static int show_memblaze_smart_log(int fd, __u32 nsid, const char *devname, printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); - printf("Total write in GB since last factory reset : %lu\n", + printf("Total write in GB since last factory reset : %"PRIu64"\n", int48_to_long(smart->items[TOTAL_WRITE].rawval)); - printf("Total read in GB since last factory reset : %lu\n", + printf("Total read in GB since last factory reset : %"PRIu64"\n", int48_to_long(smart->items[TOTAL_READ].rawval)); printf("Thermal throttling status[1:HTP in progress] : %u\n", diff --git a/nvme-print.c b/nvme-print.c index d3692a73..aff56225 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -757,10 +756,10 @@ void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname) fw_to_string(fw_log->frs[i])); } -unsigned long int48_to_long(__u8 *data) +uint64_t int48_to_long(__u8 *data) { int i; - long result = 0; + uint64_t result = 0; for (i = 0; i < 6; i++) { result *= 256; @@ -815,10 +814,10 @@ void show_intel_smart_log(struct nvme_additional_smart_log *smart, unsigned int { printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); printf("key normalized raw\n"); - printf("program_fail_count : %3d%% %lu\n", + printf("program_fail_count : %3d%% %"PRIu64"\n", smart->program_fail_cnt.norm, int48_to_long(smart->program_fail_cnt.raw)); - printf("erase_fail_count : %3d%% %lu\n", + printf("erase_fail_count : %3d%% %"PRIu64"\n", smart->erase_fail_cnt.norm, int48_to_long(smart->erase_fail_cnt.raw)); printf("wear_leveling : %3d%% min: %u, max: %u, avg: %u\n", @@ -826,35 +825,35 @@ void show_intel_smart_log(struct nvme_additional_smart_log *smart, unsigned int le16_to_cpu(smart->wear_leveling_cnt.wear_level.min), le16_to_cpu(smart->wear_leveling_cnt.wear_level.max), le16_to_cpu(smart->wear_leveling_cnt.wear_level.avg)); - printf("end_to_end_error_detection_count: %3d%% %lu\n", + printf("end_to_end_error_detection_count: %3d%% %"PRIu64"\n", smart->e2e_err_cnt.norm, int48_to_long(smart->e2e_err_cnt.raw)); - printf("crc_error_count : %3d%% %lu\n", + printf("crc_error_count : %3d%% %"PRIu64"\n", smart->crc_err_cnt.norm, int48_to_long(smart->crc_err_cnt.raw)); printf("timed_workload_media_wear : %3d%% %.3f%%\n", smart->timed_workload_media_wear.norm, ((float)int48_to_long(smart->timed_workload_media_wear.raw)) / 1024); - printf("timed_workload_host_reads : %3d%% %lu%%\n", + printf("timed_workload_host_reads : %3d%% %"PRIu64"%%\n", smart->timed_workload_host_reads.norm, int48_to_long(smart->timed_workload_host_reads.raw)); - printf("timed_workload_timer : %3d%% %lu min\n", + printf("timed_workload_timer : %3d%% %"PRIu64" min\n", smart->timed_workload_timer.norm, int48_to_long(smart->timed_workload_timer.raw)); printf("thermal_throttle_status : %3d%% %u%%, cnt: %u\n", smart->thermal_throttle_status.norm, smart->thermal_throttle_status.thermal_throttle.pct, smart->thermal_throttle_status.thermal_throttle.count); - printf("retry_buffer_overflow_count : %3d%% %lu\n", + printf("retry_buffer_overflow_count : %3d%% %"PRIu64"\n", smart->retry_buffer_overflow_cnt.norm, int48_to_long(smart->retry_buffer_overflow_cnt.raw)); - printf("pll_lock_loss_count : %3d%% %lu\n", + printf("pll_lock_loss_count : %3d%% %"PRIu64"\n", smart->pll_lock_loss_cnt.norm, int48_to_long(smart->pll_lock_loss_cnt.raw)); - printf("nand_bytes_written : %3d%% sectors: %lu\n", + printf("nand_bytes_written : %3d%% sectors: %"PRIu64"\n", smart->nand_bytes_written.norm, int48_to_long(smart->nand_bytes_written.raw)); - printf("host_bytes_written : %3d%% sectors: %lu\n", + printf("host_bytes_written : %3d%% sectors: %"PRIu64"\n", smart->host_bytes_written.norm, int48_to_long(smart->host_bytes_written.raw)); } diff --git a/nvme-print.h b/nvme-print.h index 93131c70..23ba2022 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -2,6 +2,7 @@ #define NVME_PRINT_H #include "nvme.h" +#include enum { TERSE = 0x1u, // only show a few useful fields @@ -13,7 +14,7 @@ enum { void d(unsigned char *buf, int len, int width, int group); void d_raw(unsigned char *buf, unsigned len); -unsigned long int48_to_long(__u8 *data); +uint64_t int48_to_long(__u8 *data); void __show_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode, void (*vendor_show)(__u8 *vs)); void show_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode);