shared/n-dhcp4: avoid c_min() macro to work with old GCC
This is required for the CI to pass, as CentOS has a too old version of GCC. Ideally this patch should be dropped.
This commit is contained in:

committed by
Beniamino Galvani

parent
6adade6f21
commit
d797611df5
@@ -183,7 +183,11 @@ _c_public_ void n_dhcp4_client_config_set_request_broadcast(NDhcp4ClientConfig *
|
||||
*/
|
||||
_c_public_ void n_dhcp4_client_config_set_mac(NDhcp4ClientConfig *config, const uint8_t *mac, size_t n_mac) {
|
||||
config->n_mac = n_mac;
|
||||
memcpy(config->mac, mac, c_min(n_mac, sizeof(config->mac)));
|
||||
|
||||
if (n_mac > sizeof(config->mac))
|
||||
n_mac = sizeof(config->mac);
|
||||
|
||||
memcpy(config->mac, mac, n_mac);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +213,11 @@ _c_public_ void n_dhcp4_client_config_set_mac(NDhcp4ClientConfig *config, const
|
||||
*/
|
||||
_c_public_ void n_dhcp4_client_config_set_broadcast_mac(NDhcp4ClientConfig *config, const uint8_t *mac, size_t n_mac) {
|
||||
config->n_broadcast_mac = n_mac;
|
||||
memcpy(config->broadcast_mac, mac, c_min(n_mac, sizeof(config->broadcast_mac)));
|
||||
|
||||
if (n_mac > sizeof(config->mac))
|
||||
n_mac = sizeof(config->mac);
|
||||
|
||||
memcpy(config->broadcast_mac, mac, n_mac);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -220,8 +220,9 @@ int n_dhcp4_outgoing_append(NDhcp4Outgoing *outgoing,
|
||||
/* try fitting into allowed OPTIONs space */
|
||||
if (outgoing->max_size - outgoing->i_message >= n_data + 2U + 3U + 1U) {
|
||||
/* try over-allocation to reduce allocation pressure */
|
||||
n = c_min(outgoing->max_size,
|
||||
outgoing->n_message + n_data + 128);
|
||||
n = outgoing->n_message + n_data + 128;
|
||||
if (n > outgoing->max_size)
|
||||
n = outgoing->max_size;
|
||||
m = realloc(outgoing->message, n);
|
||||
if (!m)
|
||||
return -ENOMEM;
|
||||
|
Reference in New Issue
Block a user