diff options
author | Thomas Haller <thaller@redhat.com> | 2014-02-17 13:14:47 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-02-24 21:35:33 +0100 |
commit | d3a2219cee966b2469b8a457edd3035d876859a8 (patch) | |
tree | 751a6e26dff3a2904b16b3f46ebb0fd196cafbb2 | |
parent | 6c0db3107efa6a78f88845035549b72ba5af429a (diff) | |
download | NetworkManager-d3a2219cee966b2469b8a457edd3035d876859a8.tar.gz |
replace snprintf by g_snprintf
Use the glib wrapper for snprintf.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | cli/src/settings.c | 3 | ||||
-rw-r--r-- | include/nm-test-helpers.h | 3 | ||||
-rw-r--r-- | libnm-glib/nm-object.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-adsl.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 4 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/wifi/wifi-utils.c | 2 |
7 files changed, 9 insertions, 10 deletions
diff --git a/cli/src/settings.c b/cli/src/settings.c index 10392b6b00..d420b721a5 100644 --- a/cli/src/settings.c +++ b/cli/src/settings.c @@ -1768,8 +1768,7 @@ wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer u if (channel == 0) return; - snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless)); - str[sizeof (str)-1] = 0; + g_snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless)); value = str; } diff --git a/include/nm-test-helpers.h b/include/nm-test-helpers.h index 91286b5839..cae099a848 100644 --- a/include/nm-test-helpers.h +++ b/include/nm-test-helpers.h @@ -24,6 +24,7 @@ #include <stdio.h> #include <unistd.h> +#include <glib.h> static void FAIL(const char *test_name, const char *fmt, ...) @@ -31,7 +32,7 @@ FAIL(const char *test_name, const char *fmt, ...) va_list args; char buf[500]; - snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt); + g_snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt); va_start (args, fmt); vfprintf (stderr, buf, args); diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 2fbc4f1162..61282cfbe9 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -777,8 +777,7 @@ emit_added_removed_signal (NMObject *self, char buf[50]; int ret; - ret = snprintf (buf, sizeof (buf), "%s-%s", signal_prefix, added ? "added" : "removed"); - g_assert (ret > 0); + ret = g_snprintf (buf, sizeof (buf), "%s-%s", signal_prefix, added ? "added" : "removed"); g_assert (ret < sizeof (buf)); g_signal_emit_by_name (self, buf, changed); } diff --git a/src/devices/nm-device-adsl.c b/src/devices/nm-device-adsl.c index 02acd66977..7fe626e7ca 100644 --- a/src/devices/nm-device-adsl.c +++ b/src/devices/nm-device-adsl.c @@ -206,7 +206,7 @@ br2684_create_iface (NMDeviceAdsl *self, NMSettingAdsl *s_adsl) */ while (num < 10000) { memset (&ni.ifname, 0, sizeof (ni.ifname)); - snprintf (ni.ifname, sizeof (ni.ifname), "nas%d", num); + g_snprintf (ni.ifname, sizeof (ni.ifname), "nas%d", num); err = ioctl (fd, ATM_NEWBACKENDIF, &ni); if (err == 0) { diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 0d6e28442b..9c21b19e75 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -470,13 +470,13 @@ restore_ip6_properties (NMDevice *self) if ( priv->ip6_accept_ra_save != -1 && g_file_test (priv->ip6_accept_ra_path, G_FILE_TEST_EXISTS)) { - snprintf (tmp, sizeof (tmp), "%d", priv->ip6_accept_ra_save); + g_snprintf (tmp, sizeof (tmp), "%d", priv->ip6_accept_ra_save); nm_platform_sysctl_set (priv->ip6_accept_ra_path, tmp); } if ( priv->ip6_use_tempaddr_save != -1 && g_file_test (priv->ip6_use_tempaddr_path, G_FILE_TEST_EXISTS)) { - snprintf (tmp, sizeof (tmp), "%d", priv->ip6_use_tempaddr_save); + g_snprintf (tmp, sizeof (tmp), "%d", priv->ip6_use_tempaddr_save); nm_platform_sysctl_set (priv->ip6_use_tempaddr_path, tmp); } diff --git a/src/main.c b/src/main.c index 44222404a9..a25432feef 100644 --- a/src/main.c +++ b/src/main.c @@ -155,7 +155,7 @@ write_pidfile (const char *pidfile) return FALSE; } - snprintf (pid, sizeof (pid), "%d", getpid ()); + g_snprintf (pid, sizeof (pid), "%d", getpid ()); if (write (fd, pid, strlen (pid)) < 0) fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errno)); else diff --git a/src/wifi/wifi-utils.c b/src/wifi/wifi-utils.c index ed7917e2b6..2902d0c8b0 100644 --- a/src/wifi/wifi-utils.c +++ b/src/wifi/wifi-utils.c @@ -161,7 +161,7 @@ wifi_utils_is_wifi (const char *iface, const char *sysfs_path) if (sysfs_path) { /* Check for nl80211 sysfs paths */ - snprintf (phy80211_path, sizeof (phy80211_path), "%s/phy80211", sysfs_path); + g_snprintf (phy80211_path, sizeof (phy80211_path), "%s/phy80211", sysfs_path); if ((stat (phy80211_path, &s) == 0 && (s.st_mode & S_IFDIR))) return TRUE; } |