Skip to content

Commit

Permalink
util: avoid min macro pollution
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zhangjian3032 authored and igaw committed Feb 6, 2025
1 parent acc19fc commit a9daa6a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/time.h>

#include <ccan/build_assert/build_assert.h>
#include <ccan/ccan/minmax/minmax.h>
#include <ccan/endian/endian.h>

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

while (*read < to_read) {
__u32 len = min(log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
__u32 len = min_t(__u32, log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
int ret;

ret = nvme_get_log_ana(fd, lsp, rae, *read - log, len, *read);
Expand Down
3 changes: 2 additions & 1 deletion src/nvme/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <unistd.h>

#include <ccan/array_size/array_size.h>
#include <ccan/ccan/minmax/minmax.h>
#include <ccan/endian/endian.h>

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

while (*read < to_read) {
__u32 len = min(log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
__u32 len = min_t(__u32, log_end - *read, NVME_LOG_PAGE_PDU_SIZE);
int ret;

ret = nvme_mi_admin_get_log_ana(ctrl, lsp, rae,
Expand Down
1 change: 1 addition & 0 deletions src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <netdb.h>
#include <unistd.h>

#include <ccan/ccan/minmax/minmax.h>
#include <ccan/endian/endian.h>

#include "cleanup.h"
Expand Down
2 changes: 0 additions & 2 deletions src/nvme/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ char *kv_keymatch(const char *kv, const char *key);
*/
char *startswith(const char *s, const char *prefix);

#define min(x, y) ((x) > (y) ? (y) : (x))

#define __round_mask(val, mult) ((__typeof__(val))((mult)-1))

/**
Expand Down

0 comments on commit a9daa6a

Please sign in to comment.