From c36e8488fe8f0110625970116e0f15ebc0a99182 Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Sun, 7 Apr 2019 19:00:19 +0900 Subject: [PATCH] nvme: Unify min(), max() macro as a common one 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 --- common.h | 3 +++ nvme.c | 3 --- plugins/intel/intel-nvme.c | 4 +--- plugins/micron/micron-nvme.c | 3 +-- plugins/wdc/wdc-nvme.c | 3 +-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/common.h b/common.h index 8338a3d0..aed2a991 100644 --- 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 da45422f..2770bf90 100644 --- 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; diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 7009d4f4..9aaf3676 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -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" diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index d2105237..c827baef 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -12,9 +12,8 @@ #include #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) { diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 984154e4..a2b699cf 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -31,6 +31,7 @@ #include "linux/nvme_ioctl.h" +#include "common.h" #include "nvme.h" #include "nvme-print.h" #include "nvme-ioctl.h" @@ -261,8 +262,6 @@ #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, -- 2.50.1