Commit 6c20e802 authored by Tom Gundersen's avatar Tom Gundersen

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.
parent 5596a5c6
Pipeline #40320 failed with stage
in 39 minutes and 10 seconds
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment