]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Unify min(), max() macro as a common one
authorMinwoo Im <minwoo.im.dev@gmail.com>
Sun, 7 Apr 2019 10:00:19 +0000 (19:00 +0900)
committerMinwoo Im <minwoo.im.dev@gmail.com>
Sun, 7 Apr 2019 10:00:19 +0000 (19:00 +0900)
min, max macros has been implemented on its own module.  This patch
unifies this kind of macros by moving it to common.h.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
common.h
nvme.c
plugins/intel/intel-nvme.c
plugins/micron/micron-nvme.c
plugins/wdc/wdc-nvme.c

index 8338a3d0294127939bf290bbef6bf023b1766ee1..aed2a9918b2356b502e168b68de442c792bf1460 100644 (file)
--- a/common.h
+++ b/common.h
@@ -6,4 +6,7 @@
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
+#define min(x, y) ((x) > (y) ? (y) : (x))
+#define max(x, y) ((x) > (y) ? (x) : (y))
+
 #endif
diff --git a/nvme.c b/nvme.c
index da45422fdea8650326692f54d017983f28793179..2770bf9056d359b3a8d6d4d08433d810373d778b 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -55,9 +55,6 @@
 
 #include "fabrics.h"
 
-#define min(x, y) ((x) > (y) ? (y) : (x))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
 static struct stat nvme_stat;
 const char *devicename;
 
index 7009d4f44c0dc53c8e0c6e72630e987ef5434f1c..9aaf367687313c2e1a3cfbb9d8eb1829ed4675e2 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "linux/nvme_ioctl.h"
 
+#include "common.h"
 #include "nvme.h"
 #include "nvme-print.h"
 #include "nvme-ioctl.h"
@@ -504,9 +505,6 @@ struct intel_cd_log {
     }u;
 };
 
-#define max(x,y) (x) > (y) ? (x) : (y)
-#define min(x,y) (x) > (y) ? (y) : (x)
-
 static void print_intel_nlog(struct intel_vu_nlog *intel_nlog)
 {
        printf("Version Major %u\n"
index d21052372c5c7885e3d00f524f4f2d81a583e8ef..c827baefffac02c2fa061bb678c4e135a09998a5 100644 (file)
@@ -12,9 +12,8 @@
 #include <sys/ioctl.h>
 
 #define CREATE_CMD
+#include "common.h"
 #include "micron-nvme.h"
-#define min(x, y) ((x) > (y) ? (y) : (x))
-
 
 static int micron_fw_commit(int fd, int select)
 {
index 984154e4e1146abf3877fce168a720d9185da44d..a2b699cfa36664856e8411a05bfd584913a5b291 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "linux/nvme_ioctl.h"
 
+#include "common.h"
 #include "nvme.h"
 #include "nvme-print.h"
 #include "nvme-ioctl.h"
 #define WDC_DE_DESTN_SPI                               1
 #define WDC_DE_DUMPTRACE_DESTINATION                   6
 
-#define min(x, y) ((x) > (y) ? (y) : (x))
-
 typedef enum _NVME_FEATURES_SELECT
 {
     FS_CURRENT                      = 0,