Skip to content

Commit a9daa6a

Browse files
zhangjian3032igaw
authored andcommitted
util: avoid min macro pollution
The generic min macro in util.h is too common and can conflict with other libraries. use ccan/minmax in the source files to avoid pollution. Signed-off-by: Jian Zhang <[email protected]>
1 parent acc19fc commit a9daa6a

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/nvme/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sys/time.h>
2424

2525
#include <ccan/build_assert/build_assert.h>
26+
#include <ccan/ccan/minmax/minmax.h>
2627
#include <ccan/endian/endian.h>
2728

2829
#include "ioctl.h"
@@ -503,7 +504,7 @@ static int read_ana_chunk(int fd, enum nvme_log_ana_lsp lsp, bool rae,
503504
}
504505

505506
while (*read < to_read) {
506-
__u32 len = min(log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
507+
__u32 len = min_t(__u32, log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
507508
int ret;
508509

509510
ret = nvme_get_log_ana(fd, lsp, rae, *read - log, len, *read);

src/nvme/mi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <unistd.h>
1515

1616
#include <ccan/array_size/array_size.h>
17+
#include <ccan/ccan/minmax/minmax.h>
1718
#include <ccan/endian/endian.h>
1819

1920
#include "log.h"
@@ -1021,7 +1022,7 @@ static int read_ana_chunk(nvme_mi_ctrl_t ctrl, enum nvme_log_ana_lsp lsp, bool r
10211022
}
10221023

10231024
while (*read < to_read) {
1024-
__u32 len = min(log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
1025+
__u32 len = min_t(__u32, log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
10251026
int ret;
10261027

10271028
ret = nvme_mi_admin_get_log_ana(ctrl, lsp, rae,

src/nvme/util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <netdb.h>
2323
#include <unistd.h>
2424

25+
#include <ccan/ccan/minmax/minmax.h>
2526
#include <ccan/endian/endian.h>
2627

2728
#include "cleanup.h"

src/nvme/util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ char *kv_keymatch(const char *kv, const char *key);
560560
*/
561561
char *startswith(const char *s, const char *prefix);
562562

563-
#define min(x, y) ((x) > (y) ? (y) : (x))
564-
565563
#define __round_mask(val, mult) ((__typeof__(val))((mult)-1))
566564

567565
/**

0 commit comments

Comments
 (0)