replace snprintf by g_snprintf

Use the glib wrapper for snprintf.

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-02-17 13:14:47 +01:00
parent 6c0db3107e
commit d3a2219cee
7 changed files with 9 additions and 10 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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) {

View file

@ -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);
}

View file

@ -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

View file

@ -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;
}