From d65db02ab494d16c0c4638d0207d5010901d20a1 Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Tue, 29 Nov 2016 10:25:27 -0500 Subject: [PATCH] Show negative temperatures in smart log. Issue: https://github.com/linux-nvme/nvme-cli/issues/141 Signed-off-by: Keith Busch --- nvme-print.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvme-print.c b/nvme-print.c index 34c146d..a4b0188 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -773,12 +773,12 @@ void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char { /* convert temperature from Kelvin to Celsius */ int c; - unsigned int temperature = ((smart->temperature[1] << 8) | + int temperature = ((smart->temperature[1] << 8) | smart->temperature[0]) - 273; printf("Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); printf("critical_warning : %#x\n", smart->critical_warning); - printf("temperature : %u C\n", temperature); + printf("temperature : %d C\n", temperature); printf("available_spare : %u%%\n", smart->avail_spare); printf("available_spare_threshold : %u%%\n", smart->spare_thresh); printf("percentage_used : %u%%\n", smart->percent_used); -- 2.49.0