diff options
author | Tom Gundersen <teg@jklm.no> | 2019-05-31 16:28:15 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-07-05 11:04:32 +0200 |
commit | d797611df59abe9c4d4836a7f3c6fa28a8311b01 (patch) | |
tree | 0b4b938a4f024dd23b40a615b544fe06861fa78c /shared | |
parent | 6adade6f21d5fefd0a00abee64f99ff96a54f0f3 (diff) | |
download | NetworkManager-d797611df59abe9c4d4836a7f3c6fa28a8311b01.tar.gz |
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.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-client.c | 12 | ||||
-rw-r--r-- | shared/n-dhcp4/src/n-dhcp4-outgoing.c | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-client.c b/shared/n-dhcp4/src/n-dhcp4-client.c index a492a74c61..5f7794fb14 100644 --- a/shared/n-dhcp4/src/n-dhcp4-client.c +++ b/shared/n-dhcp4/src/n-dhcp4-client.c @@ -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); } /** diff --git a/shared/n-dhcp4/src/n-dhcp4-outgoing.c b/shared/n-dhcp4/src/n-dhcp4-outgoing.c index bb33bbdbe5..c44b5880aa 100644 --- a/shared/n-dhcp4/src/n-dhcp4-outgoing.c +++ b/shared/n-dhcp4/src/n-dhcp4-outgoing.c @@ -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; |