Skip to content

Commit 75f77db

Browse files
carlos-stuartnashif
authored andcommitted
include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++ application with a third-party toolchain such as GNU ARM Embedded when using some STL headers i.e. <chrono>. This is because there are actual C++ functions called min and max defined in some of the STL headers and these macros interfere with them. By changing the macros to UPPERCASE, which is consistent with almost all other pre-processor macros this naming conflict is avoided. All files that use these macros have been updated. Signed-off-by: Carlos Stuart <[email protected]>
1 parent 413ede4 commit 75f77db

File tree

106 files changed

+229
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+229
-229
lines changed

boards/posix/native_posix/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void posix_exit(int exit_code)
3636
{
3737
static int max_exit_code;
3838

39-
max_exit_code = max(exit_code, max_exit_code);
39+
max_exit_code = MAX(exit_code, max_exit_code);
4040
/*
4141
* posix_soc_clean_up may not return if this is called from a SW thread,
4242
* but instead it would get posix_exit() recalled again

boards/posix/native_posix/timer_model.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void hwtimer_set_real_time_mode(bool new_rt)
126126

127127
static void hwtimer_update_timer(void)
128128
{
129-
hw_timer_timer = min(hw_timer_tick_timer, hw_timer_awake_timer);
129+
hw_timer_timer = MIN(hw_timer_tick_timer, hw_timer_awake_timer);
130130
}
131131

132132
static inline void host_clock_gettime(struct timespec *tv)

drivers/bluetooth/hci/h4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static size_t h4_discard(struct device *uart, size_t len)
232232
{
233233
u8_t buf[33];
234234

235-
return uart_fifo_read(uart, buf, min(len, sizeof(buf)));
235+
return uart_fifo_read(uart, buf, MIN(len, sizeof(buf)));
236236
}
237237

238238
static inline void read_payload(void)

drivers/entropy/entropy_sam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int entropy_sam_get_entropy(struct device *dev, u8_t *buffer,
5858
}
5959

6060
value = trng->TRNG_ODATA;
61-
to_copy = min(length, sizeof(value));
61+
to_copy = MIN(length, sizeof(value));
6262

6363
memcpy(buffer, &value, to_copy);
6464
buffer += to_copy;

drivers/entropy/fake_entropy_native_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static int entropy_native_posix_get_entropy(struct device *dev, u8_t *buffer,
3535
*/
3636
long int value = random();
3737

38-
size_t to_copy = min(length, sizeof(long int));
38+
size_t to_copy = MIN(length, sizeof(long int));
3939

4040
memcpy(buffer, &value, to_copy);
4141
buffer += to_copy;

drivers/flash/flash_sam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int flash_sam_write(struct device *dev, off_t offset,
185185

186186
/* Maximum size without crossing a page */
187187
eop_len = -(offset | ~(IFLASH_PAGE_SIZE - 1));
188-
write_len = min(len, eop_len);
188+
write_len = MIN(len, eop_len);
189189

190190
rc = flash_sam_write_page(dev, offset, data8, write_len);
191191
if (rc < 0) {

drivers/flash/soc_flash_nios2_qspi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int flash_nios2_qspi_erase(struct device *dev, off_t offset, size_t len)
105105
}
106106

107107
/* calculate the byte size of data to be written in a sector */
108-
length_to_erase = min(qspi_dev->sector_size - offset_in_block,
108+
length_to_erase = MIN(qspi_dev->sector_size - offset_in_block,
109109
remaining_length);
110110

111111
/* Erase sector */
@@ -297,7 +297,7 @@ static int flash_nios2_qspi_write(struct device *dev, off_t offset,
297297
}
298298

299299
/* calculate the byte size of data to be written in a sector */
300-
length_to_write = min(qspi_dev->sector_size - offset_in_block,
300+
length_to_write = MIN(qspi_dev->sector_size - offset_in_block,
301301
remaining_length);
302302

303303
rc = flash_nios2_qspi_write_block(dev,

drivers/i2c/i2c_dw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ static inline void _i2c_dw_data_ask(struct device *dev)
6969
tx_empty = I2C_DW_FIFO_DEPTH - regs->ic_txflr;
7070

7171
/* Figure out how many bytes we can request */
72-
cnt = min(I2C_DW_FIFO_DEPTH, dw->request_bytes);
73-
cnt = min(min(tx_empty, rx_empty), cnt);
72+
cnt = MIN(I2C_DW_FIFO_DEPTH, dw->request_bytes);
73+
cnt = MIN(MIN(tx_empty, rx_empty), cnt);
7474

7575
while (cnt > 0) {
7676
/* Tell controller to get another byte */

drivers/i2c/i2c_esp32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int i2c_esp32_read_msg(struct device *dev, u16_t addr,
388388

389389
for (; msg.len; cmd = (void *)I2C_COMD0_REG(config->index)) {
390390
volatile struct i2c_esp32_cmd *wait_cmd = NULL;
391-
u32_t to_read = min(I2C_ESP32_BUFFER_SIZE, msg.len - 1);
391+
u32_t to_read = MIN(I2C_ESP32_BUFFER_SIZE, msg.len - 1);
392392

393393
/* Might be the last byte, in which case, `to_read` will
394394
* be 0 here. See comment below.
@@ -464,7 +464,7 @@ static int i2c_esp32_write_msg(struct device *dev, u16_t addr,
464464
cmd = i2c_esp32_write_addr(dev, cmd, &msg, addr);
465465

466466
for (; msg.len; cmd = (void *)I2C_COMD0_REG(config->index)) {
467-
u32_t to_send = min(I2C_ESP32_BUFFER_SIZE, msg.len);
467+
u32_t to_send = MIN(I2C_ESP32_BUFFER_SIZE, msg.len);
468468
u32_t i;
469469
int ret;
470470

drivers/spi/spi_sam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int spi_sam_configure(struct device *dev,
9292

9393
/* Use the requested or next higest possible frequency */
9494
div = SOC_ATMEL_SAM_MCK_FREQ_HZ / config->frequency;
95-
div = max(1, min(UINT8_MAX, div));
95+
div = MAX(1, MIN(UINT8_MAX, div));
9696
spi_csr |= SPI_CSR_SCBR(div);
9797

9898
regs->SPI_CR = SPI_CR_SPIDIS; /* Disable SPI */

drivers/spi/spi_sam0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int spi_sam0_configure(struct device *dev,
9595

9696
/* Use the requested or next higest possible frequency */
9797
div = (SOC_ATMEL_SAM0_GCLK0_FREQ_HZ / config->frequency) / 2 - 1;
98-
div = max(0, min(UINT8_MAX, div));
98+
div = MAX(0, MIN(UINT8_MAX, div));
9999

100100
/* Update the configuration only if it has changed */
101101
if (regs->CTRLA.reg != ctrla.reg || regs->CTRLB.reg != ctrlb.reg ||

drivers/timer/arcv2_timer0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
194194
#if defined(CONFIG_TICKLESS_KERNEL)
195195
u32_t delay;
196196

197-
ticks = min(MAX_TICKS, max(ticks - 1, 0));
197+
ticks = MIN(MAX_TICKS, MAX(ticks - 1, 0));
198198

199199
/* Desired delay in the future */
200200
delay = (ticks == 0) ? MIN_DELAY : ticks * CYC_PER_TICK;

drivers/timer/cortex_m_systick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
9393
#if defined(CONFIG_TICKLESS_KERNEL) && !defined(CONFIG_QEMU_TICKLESS_WORKAROUND)
9494
u32_t delay;
9595

96-
ticks = min(MAX_TICKS, max(ticks - 1, 0));
96+
ticks = MIN(MAX_TICKS, MAX(ticks - 1, 0));
9797

9898
/* Desired delay in the future */
9999
delay = (ticks == 0) ? MIN_DELAY : ticks * CYC_PER_TICK;

drivers/timer/hpet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
109109
}
110110

111111
ticks = ticks == K_FOREVER ? max_ticks : ticks;
112-
ticks = max(min(ticks - 1, (s32_t)max_ticks), 0);
112+
ticks = MAX(MIN(ticks - 1, (s32_t)max_ticks), 0);
113113

114114
k_spinlock_key_t key = k_spin_lock(&lock);
115115
u32_t now = MAIN_COUNTER_REG, cyc;

drivers/timer/nrf_rtc_timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
128128

129129
#ifdef CONFIG_TICKLESS_KERNEL
130130
ticks = (ticks == K_FOREVER) ? MAX_TICKS : ticks;
131-
ticks = max(min(ticks - 1, (s32_t)MAX_TICKS), 0);
131+
ticks = MAX(MIN(ticks - 1, (s32_t)MAX_TICKS), 0);
132132

133133
/*
134134
* Get the requested delay in tick-aligned cycles. Increase
135135
* by one tick to round up so we don't timeout early due to
136136
* cycles elapsed since the last tick. Cap at the maximum
137137
* tick-aligned delta.
138138
*/
139-
u32_t cyc = min((1 + ticks) * CYC_PER_TICK, MAX_DELAY);
139+
u32_t cyc = MIN((1 + ticks) * CYC_PER_TICK, MAX_DELAY);
140140

141141
u32_t key = irq_lock();
142142
u32_t d = counter_sub(counter(), last_count);

drivers/timer/riscv_machine_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
9595
}
9696

9797
ticks = ticks == K_FOREVER ? MAX_TICKS : ticks;
98-
ticks = max(min(ticks - 1, (s32_t)MAX_TICKS), 0);
98+
ticks = MAX(MIN(ticks - 1, (s32_t)MAX_TICKS), 0);
9999

100100
k_spinlock_key_t key = k_spin_lock(&lock);
101101
u64_t now = mtime();

drivers/timer/sam0_rtc_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
205205
#ifdef CONFIG_TICKLESS_KERNEL
206206

207207
ticks = (ticks == K_FOREVER) ? MAX_TICKS : ticks;
208-
ticks = max(min(ticks - 1, (s32_t) MAX_TICKS), 0);
208+
ticks = MAX(MIN(ticks - 1, (s32_t) MAX_TICKS), 0);
209209

210210
/* Compute number of RTC cycles until the next timeout. */
211211
u32_t count = rtc_count();

drivers/timer/xtensa_sys_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
8282

8383
#if defined(CONFIG_TICKLESS_KERNEL) && !defined(CONFIG_QEMU_TICKLESS_WORKAROUND)
8484
ticks = ticks == K_FOREVER ? MAX_TICKS : ticks;
85-
ticks = max(min(ticks - 1, (s32_t)MAX_TICKS), 0);
85+
ticks = MAX(MIN(ticks - 1, (s32_t)MAX_TICKS), 0);
8686

8787
k_spinlock_key_t key = k_spin_lock(&lock);
8888
u32_t curr = ccount(), cyc;

drivers/usb/device/usb_dc_nrfx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
16741674

16751675
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
16761676

1677-
bytes_to_copy = min(max_data_len, ep_ctx->buf.len);
1677+
bytes_to_copy = MIN(max_data_len, ep_ctx->buf.len);
16781678

16791679
if (!data && !max_data_len) {
16801680
if (read_bytes) {

drivers/usb/device/usb_dc_sam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const cfg)
475475
* Map the endpoint size to the buffer size. Only power of 2 buffer
476476
* sizes between 8 and 1024 are possible, get the next power of 2.
477477
*/
478-
log2ceil_mps = 32 - __builtin_clz((max(cfg->ep_mps, 8) << 1) - 1) - 1;
478+
log2ceil_mps = 32 - __builtin_clz((MAX(cfg->ep_mps, 8) << 1) - 1) - 1;
479479
regval |= USBHS_DEVEPTCFG_EPSIZE(log2ceil_mps - 3);
480480
dev_data.ep_data[ep_idx].mps = cfg->ep_mps;
481481

@@ -695,7 +695,7 @@ int usb_dc_ep_write(u8_t ep, const u8_t *data, u32_t data_len, u32_t *ret_bytes)
695695
}
696696

697697
/* Write the data to the FIFO */
698-
packet_len = min(data_len, dev_data.ep_data[ep_idx].mps);
698+
packet_len = MIN(data_len, dev_data.ep_data[ep_idx].mps);
699699
for (int i = 0; i < packet_len; i++) {
700700
usb_dc_ep_fifo_put(ep_idx, data[i]);
701701
}

drivers/usb/device/usb_dc_sam0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int usb_dc_ep_read_ex(u8_t ep, u8_t *buf, u32_t max_data_len,
490490
}
491491

492492
remain = bytes - data->out_at;
493-
take = min(max_data_len, remain);
493+
take = MIN(max_data_len, remain);
494494
memcpy(buf, (u8_t *)addr + data->out_at, take);
495495

496496
if (read_bytes != NULL) {

drivers/usb/device/usb_dc_stm32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
797797
* previously stored in the buffer.
798798
*/
799799
if (data) {
800-
read_count = min(read_count, max_data_len);
800+
read_count = MIN(read_count, max_data_len);
801801
memcpy(data, usb_dc_stm32_state.ep_buf[EP_IDX(ep)] +
802802
ep_state->read_offset, read_count);
803803
ep_state->read_count -= read_count;

drivers/wifi/eswifi/eswifi_bus_spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static int eswifi_spi_request(struct eswifi_dev *eswifi, char *cmd, size_t clen,
159159
}
160160

161161
while (eswifi_spi_cmddata_ready(spi) && to_read) {
162-
to_read = min(rlen - offset, to_read);
162+
to_read = MIN(rlen - offset, to_read);
163163
memset(rsp + offset, 0, to_read);
164164
eswifi_spi_read(eswifi, rsp + offset, to_read);
165165
offset += to_read;

ext/lib/mgmt/mcumgr/cmd/log_mgmt/port/zephyr/src/zephyr_log_mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ zephyr_log_mgmt_walk_cb(struct mdlog *log, struct mdlog_offset *log_offset,
121121
return 0;
122122
}
123123

124-
read_len = min(len - sizeof ueh, LOG_MGMT_BODY_LEN - sizeof ueh);
124+
read_len = MIN(len - sizeof ueh, LOG_MGMT_BODY_LEN - sizeof ueh);
125125
rc = mdlog_read(log, desciptor, zephyr_log_mgmt_walk_arg->body, sizeof ueh,
126126
read_len);
127127
if (rc < 0) {

include/arch/arc/arch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern "C" {
6868
#define STACK_GUARD_SIZE 0
6969
#endif /* CONFIG_MPU_STACK_GUARD */
7070

71-
#define STACK_SIZE_ALIGN(x) max(STACK_ALIGN, x)
71+
#define STACK_SIZE_ALIGN(x) MAX(STACK_ALIGN, x)
7272

7373

7474
/**
@@ -91,7 +91,7 @@ extern "C" {
9191

9292
#define _ARCH_THREAD_STACK_LEN(size) \
9393
(POW2_CEIL(STACK_SIZE_ALIGN(size)) + \
94-
max(POW2_CEIL(STACK_SIZE_ALIGN(size)), \
94+
MAX(POW2_CEIL(STACK_SIZE_ALIGN(size)), \
9595
POW2_CEIL(STACK_GUARD_SIZE + CONFIG_PRIVILEGED_STACK_SIZE)))
9696

9797
#define _ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \

include/arch/arm/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ extern "C" {
109109
#if defined(CONFIG_USERSPACE)
110110
#define STACK_ALIGN CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
111111
#else
112-
#define STACK_ALIGN max(STACK_ALIGN_SIZE, MPU_GUARD_ALIGN_AND_SIZE)
112+
#define STACK_ALIGN MAX(STACK_ALIGN_SIZE, MPU_GUARD_ALIGN_AND_SIZE)
113113
#endif
114114

115115
/**

include/arch/x86/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ extern struct task_state_segment _main_tss;
613613

614614
#define _ARCH_THREAD_STACK_LEN(size) \
615615
(ROUND_UP((size), \
616-
max(_STACK_BASE_ALIGN, _STACK_SIZE_ALIGN)) + \
616+
MAX(_STACK_BASE_ALIGN, _STACK_SIZE_ALIGN)) + \
617617
_STACK_GUARD_SIZE)
618618

619619
#define _ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \

include/misc/util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ constexpr size_t ARRAY_SIZE(T(&)[N]) { return N; }
8686
#define INLINE
8787
#endif
8888

89-
#ifndef max
90-
#define max(a, b) (((a) > (b)) ? (a) : (b))
89+
#ifndef MAX
90+
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
9191
#endif
9292

93-
#ifndef min
94-
#define min(a, b) (((a) < (b)) ? (a) : (b))
93+
#ifndef MIN
94+
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
9595
#endif
9696

9797
static inline int is_power_of_two(unsigned int x)

include/net/lldp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extern "C" {
9595
* to zero so LLDP Rx agents can invalidate the entry related to this node.
9696
*/
9797
#define NET_LLDP_TTL \
98-
min((CONFIG_NET_LLDP_TX_INTERVAL * CONFIG_NET_LLDP_TX_HOLD) + 1, 65535)
98+
MIN((CONFIG_NET_LLDP_TX_INTERVAL * CONFIG_NET_LLDP_TX_HOLD) + 1, 65535)
9999

100100

101101
struct net_if;

kernel/pipes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void k_pipe_cleanup(struct k_pipe *pipe)
197197
static size_t pipe_xfer(unsigned char *dest, size_t dest_size,
198198
const unsigned char *src, size_t src_size)
199199
{
200-
size_t num_bytes = min(dest_size, src_size);
200+
size_t num_bytes = MIN(dest_size, src_size);
201201
const unsigned char *end = src + num_bytes;
202202

203203
while (src != end) {
@@ -227,7 +227,7 @@ static size_t pipe_buffer_put(struct k_pipe *pipe,
227227

228228

229229
for (i = 0; i < 2; i++) {
230-
run_length = min(pipe->size - pipe->bytes_used,
230+
run_length = MIN(pipe->size - pipe->bytes_used,
231231
pipe->size - pipe->write_index);
232232

233233
bytes_copied = pipe_xfer(pipe->buffer + pipe->write_index,
@@ -263,7 +263,7 @@ static size_t pipe_buffer_get(struct k_pipe *pipe,
263263
int i;
264264

265265
for (i = 0; i < 2; i++) {
266-
run_length = min(pipe->bytes_used,
266+
run_length = MIN(pipe->bytes_used,
267267
pipe->size - pipe->read_index);
268268

269269
bytes_copied = pipe_xfer(dest + num_bytes_read,

kernel/timeout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static s32_t next_timeout(void)
6262
{
6363
int maxw = can_wait_forever ? K_FOREVER : INT_MAX;
6464
struct _timeout *to = first();
65-
s32_t ret = to == NULL ? maxw : max(0, to->dticks - elapsed());
65+
s32_t ret = to == NULL ? maxw : MAX(0, to->dticks - elapsed());
6666

6767
#ifdef CONFIG_TIMESLICING
6868
if (_current_cpu->slice_ticks && _current_cpu->slice_ticks < ret) {
@@ -76,7 +76,7 @@ void _add_timeout(struct _timeout *to, _timeout_func_t fn, s32_t ticks)
7676
{
7777
__ASSERT(!sys_dnode_is_linked(&to->node), "");
7878
to->fn = fn;
79-
ticks = max(1, ticks);
79+
ticks = MAX(1, ticks);
8080

8181
LOCKED(&timeout_lock) {
8282
struct _timeout *t;

lib/os/ring_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ u32_t ring_buf_put_claim(struct ring_buf *buf, u8_t **data, u32_t size)
114114
buf->misc.byte_mode.tmp_tail);
115115

116116
/* Limit requested size to available size. */
117-
size = min(size, space);
117+
size = MIN(size, space);
118118
trail_size = buf->size - buf->misc.byte_mode.tmp_tail;
119119

120120
/* Limit allocated size to trail size. */
121-
allocated = min(trail_size, size);
121+
allocated = MIN(trail_size, size);
122122

123123
*data = &buf->buf.buf8[buf->misc.byte_mode.tmp_tail];
124124
buf->misc.byte_mode.tmp_tail =
@@ -169,10 +169,10 @@ u32_t ring_buf_get_claim(struct ring_buf *buf, u8_t **data, u32_t size)
169169
trail_size = buf->size - buf->misc.byte_mode.tmp_head;
170170

171171
/* Limit requested size to available size. */
172-
granted_size = min(size, space);
172+
granted_size = MIN(size, space);
173173

174174
/* Limit allocated size to trail size. */
175-
granted_size = min(trail_size, granted_size);
175+
granted_size = MIN(trail_size, granted_size);
176176

177177
*data = &buf->buf.buf8[buf->misc.byte_mode.tmp_head];
178178
buf->misc.byte_mode.tmp_head =

samples/bluetooth/eddystone/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static ssize_t write_adv_data(struct bt_conn *conn,
487487
* controlled by characteristics 4 (Radio Tx Power) and
488488
* 5 (Advertised Tx Power).
489489
*/
490-
slot->ad[2].data_len = min(slot->ad[2].data_len,
490+
slot->ad[2].data_len = MIN(slot->ad[2].data_len,
491491
len + EDS_URL_WRITE_OFFSET);
492492
memcpy(&slot->ad[2].data + EDS_URL_WRITE_OFFSET, buf,
493493
slot->ad[2].data_len - EDS_URL_WRITE_OFFSET);

0 commit comments

Comments
 (0)