device: cleanup converting mtu to string for sysctl_set()

Use %u for unsigned type and cast the guint32 to (unsigned).
While at it, increase the stack-allocated buffer to 64 bytes
(it doesn't hurt) and use nm_sprintf_buf().
This commit is contained in:
Thomas Haller 2017-01-13 11:14:12 +01:00
parent 334a8a54be
commit 85c38d18a0

View file

@ -6636,7 +6636,6 @@ nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
guint32 ip_mtu = get_ip_mtu (self);
guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", ip_mtu);
char val[16];
priv->ip6_mtu = mtu ?: plat_mtu;
@ -6659,8 +6658,10 @@ nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
}
if (priv->ip6_mtu != plat_mtu) {
g_snprintf (val, sizeof (val), "%d", mtu);
nm_device_ipv6_sysctl_set (self, "mtu", val);
char val[64];
nm_device_ipv6_sysctl_set (self, "mtu",
nm_sprintf_buf (val, "%u", (unsigned) mtu));
}
}