From 85c38d18a00ef9c7dfca4bce2ffac8fab2c377ef Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 13 Jan 2017 11:14:12 +0100 Subject: [PATCH] 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(). --- src/devices/nm-device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f172ec2c6f..fe5e930e41 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -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)); } }