all: cache errno in local variable before using it

This commit is contained in:
Thomas Haller
2019-01-31 13:29:21 +01:00
parent b7bb744973
commit 047998f80a
34 changed files with 217 additions and 147 deletions

View File

@@ -5022,7 +5022,7 @@ _nl_send_nlmsghdr (NMPlatform *platform,
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
guint32 seq;
int nle;
int errsv;
nm_assert (nlhdr);
@@ -5051,13 +5051,13 @@ _nl_send_nlmsghdr (NMPlatform *platform,
try_count = 0;
again:
nle = sendmsg (nl_socket_get_fd (priv->nlh), &msg, 0);
if (nle < 0) {
nle = errno;
if (nle == EINTR && try_count++ < 100)
errsv = sendmsg (nl_socket_get_fd (priv->nlh), &msg, 0);
if (errsv < 0) {
errsv = errno;
if (errsv == EINTR && try_count++ < 100)
goto again;
_LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", g_strerror (nle), nle);
return -nle;
_LOGD ("netlink: nl-send-nlmsghdr: failed sending message: %s (%d)", g_strerror (errsv), errsv);
return -nm_errno_from_native (errsv);
}
}
@@ -6096,6 +6096,7 @@ link_set_sriov_params (NMPlatform *platform,
gint64 current_num;
char ifname[IFNAMSIZ];
char buf[64];
int errsv;
if (!nm_platform_netns_push (platform, &netns))
return FALSE;
@@ -6143,7 +6144,8 @@ link_set_sriov_params (NMPlatform *platform,
ifname,
"device/sriov_numvfs"),
"0")) {
_LOGW ("link: couldn't reset SR-IOV num_vfs: %s", strerror (errno));
errsv = errno;
_LOGW ("link: couldn't reset SR-IOV num_vfs: %s", strerror (errsv));
return FALSE;
}
}
@@ -6158,7 +6160,8 @@ link_set_sriov_params (NMPlatform *platform,
ifname,
"device/sriov_drivers_autoprobe"),
nm_sprintf_buf (buf, "%d", (int) autoprobe))) {
_LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errno));
errsv = errno;
_LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errsv));
return FALSE;
}
@@ -6167,7 +6170,8 @@ link_set_sriov_params (NMPlatform *platform,
ifname,
"device/sriov_numvfs"),
nm_sprintf_buf (buf, "%u", num_vfs))) {
_LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, strerror (errno));
errsv = errno;
_LOGW ("link: couldn't set SR-IOV num_vfs to %d: %s", num_vfs, strerror (errsv));
return FALSE;
}