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 <carlosstuart1970@gmail.com>
This commit is contained in:
Carlos Stuart 2019-02-11 17:14:19 +00:00 committed by Anas Nashif
commit 75f77db432
106 changed files with 229 additions and 229 deletions

View file

@ -214,7 +214,7 @@ static char *sprint_token(const u8_t *token, u8_t tkl)
if (token && tkl != LWM2M_MSG_TOKEN_LEN_SKIP) {
int i;
tkl = min(tkl, sizeof(buf) / 2 - 1);
tkl = MIN(tkl, sizeof(buf) / 2 - 1);
for (i = 0; i < tkl; i++) {
*ptr++ = to_hex_digit(token[i] >> 4);
@ -541,7 +541,7 @@ static int engine_add_observer(struct lwm2m_message *msg,
observe_node_data[i].event_timestamp =
observe_node_data[i].last_timestamp;
observe_node_data[i].min_period_sec = attrs.pmin;
observe_node_data[i].max_period_sec = max(attrs.pmax, attrs.pmin);
observe_node_data[i].max_period_sec = MAX(attrs.pmax, attrs.pmin);
observe_node_data[i].format = format;
observe_node_data[i].counter = 1U;
sys_slist_append(&engine_observer_list,
@ -2337,7 +2337,7 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj,
/* loop through options to parse attribute */
for (i = 0; i < nr_opt; i++) {
int limit = min(options[i].len, 5), plen = 0, vlen;
int limit = MIN(options[i].len, 5), plen = 0, vlen;
float32_value_t val = { 0 };
type = 0U;
@ -2595,9 +2595,9 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj,
obs->path.obj_id, obs->path.obj_inst_id,
obs->path.res_id, obs->path.level,
obs->min_period_sec, obs->max_period_sec,
nattrs.pmin, max(nattrs.pmin, nattrs.pmax));
nattrs.pmin, MAX(nattrs.pmin, nattrs.pmax));
obs->min_period_sec = (u32_t)nattrs.pmin;
obs->max_period_sec = (u32_t)max(nattrs.pmin, nattrs.pmax);
obs->max_period_sec = (u32_t)MAX(nattrs.pmin, nattrs.pmax);
(void)memset(&nattrs, 0, sizeof(nattrs));
}