Use g_(v)snprintf so we need less wrappers.

Wed, 30 Oct 2019 23:25:39 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 30 Oct 2019 23:25:39 -0400
changeset 40094
8e6d91e4dd8f
parent 40093
dd7183cf0a71
child 40095
330279f77e0d

Use g_(v)snprintf so we need less wrappers.

finch/gntaccount.c file | annotate | diff | comparison | revisions
finch/gntrequest.c file | annotate | diff | comparison | revisions
libpurple/protocols/bonjour/bonjour_ft.c file | annotate | diff | comparison | revisions
libpurple/protocols/bonjour/mdns_common.c file | annotate | diff | comparison | revisions
libpurple/protocols/bonjour/xmpp.c file | annotate | diff | comparison | revisions
libpurple/protocols/gg/oauth/oauth.c file | annotate | diff | comparison | revisions
libpurple/win32/libc_interface.h file | annotate | diff | comparison | revisions
libpurple/xmlnode.c file | annotate | diff | comparison | revisions
pidgin/gtknotify.c file | annotate | diff | comparison | revisions
pidgin/gtkutils.c file | annotate | diff | comparison | revisions
pidgin/libpidgin.c file | annotate | diff | comparison | revisions
pidgin/win32/untar.c file | annotate | diff | comparison | revisions
--- a/finch/gntaccount.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/finch/gntaccount.c	Wed Oct 30 23:25:39 2019 -0400
@@ -482,7 +482,7 @@
 					if (account)
 						value = purple_account_get_int(account,
 								purple_account_option_get_setting(option), value);
-					snprintf(str, sizeof(str), "%d", value);
+					g_snprintf(str, sizeof(str), "%d", value);
 					gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT);
 					gnt_entry_set_text(GNT_ENTRY(entry), str);
 				}
--- a/finch/gntrequest.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/finch/gntrequest.c	Wed Oct 30 23:25:39 2019 -0400
@@ -462,7 +462,7 @@
 	int val = purple_request_field_int_get_default_value(field);
 	GntWidget *entry;
 
-	snprintf(str, sizeof(str), "%d", val);
+	g_snprintf(str, sizeof(str), "%d", val);
 	entry = gnt_entry_new(str);
 	gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT);
 	return entry;
--- a/libpurple/protocols/bonjour/bonjour_ft.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/protocols/bonjour/bonjour_ft.c	Wed Oct 30 23:25:39 2019 -0400
@@ -1027,8 +1027,9 @@
 
 	memset(dstaddr, 0, 41);
 	p = dstaddr;
-	for(i = 0; i < 20; i++, p += 2)
-		snprintf(p, 3, "%02x", hashval[i]);
+	for (i = 0; i < 20; i++, p += 2) {
+		g_snprintf(p, 3, "%02x", hashval[i]);
+	}
 
 	xf->proxy_info = purple_proxy_info_new();
 	purple_proxy_info_set_proxy_type(xf->proxy_info, PURPLE_PROXY_SOCKS5);
--- a/libpurple/protocols/bonjour/mdns_common.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/protocols/bonjour/mdns_common.c	Wed Oct 30 23:25:39 2019 -0400
@@ -85,7 +85,7 @@
 	const char *jid, *aim, *email;
 
 	/* Convert the port to a string */
-	snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
+	g_snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
 
 	jid = purple_account_get_string(data->account, "jid", NULL);
 	aim = purple_account_get_string(data->account, "AIM", NULL);
--- a/libpurple/protocols/bonjour/xmpp.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/protocols/bonjour/xmpp.c	Wed Oct 30 23:25:39 2019 -0400
@@ -1467,6 +1467,5 @@
 	    !IN6_IS_ADDR_LINKLOCAL(&in6_addr))
 		return;
 
-	snprintf(ip + strlen(ip), len_remain, "%%%d",
-		 interface_param);
+	g_snprintf(ip + strlen(ip), len_remain, "%%%d", interface_param);
 }
--- a/libpurple/protocols/gg/oauth/oauth.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/protocols/gg/oauth/oauth.c	Wed Oct 30 23:25:39 2019 -0400
@@ -104,9 +104,9 @@
 		nonce[sizeof(nonce) - 1] = 0;
 	}
 
-	if (gg_oauth_static_timestamp == NULL)
-		snprintf(timestamp, sizeof(timestamp), "%ld", time(NULL));
-	else {
+	if (gg_oauth_static_timestamp == NULL) {
+		g_snprintf(timestamp, sizeof(timestamp), "%ld", time(NULL));
+	} else {
 		strncpy(timestamp, gg_oauth_static_timestamp, sizeof(timestamp) - 1);
 		timestamp[sizeof(timestamp) - 1] = 0;
 	}
--- a/libpurple/win32/libc_interface.h	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/win32/libc_interface.h	Wed Oct 30 23:25:39 2019 -0400
@@ -136,8 +136,6 @@
 /* stdio.h */
 #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3 || \
 	!defined(IS_WIN32_CROSS_COMPILED)
-#  undef snprintf
-#  define snprintf _snprintf
 #  undef vsnprintf
 #  define vsnprintf _vsnprintf
 #endif
--- a/libpurple/xmlnode.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/libpurple/xmlnode.c	Wed Oct 30 23:25:39 2019 -0400
@@ -711,7 +711,7 @@
 	xpd->error = TRUE;
 
 	va_start(args, msg);
-	vsnprintf(errmsg, sizeof(errmsg), msg, args);
+	g_vsnprintf(errmsg, sizeof(errmsg), msg, args);
 	va_end(args);
 
 	purple_debug_error("xmlnode", "Error parsing xml file: %s", errmsg);
--- a/pidgin/gtknotify.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/pidgin/gtknotify.c	Wed Oct 30 23:25:39 2019 -0400
@@ -1157,7 +1157,9 @@
 userinfo_hash(PurpleAccount *account, const char *who)
 {
 	char key[256];
-	snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who));
+	g_snprintf(key, sizeof(key), "%s - %s",
+	           purple_account_get_username(account),
+	           purple_normalize(account, who));
 	return g_utf8_strup(key, -1);
 }
 
--- a/pidgin/gtkutils.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/pidgin/gtkutils.c	Wed Oct 30 23:25:39 2019 -0400
@@ -2425,10 +2425,10 @@
 	gtk_style_context_get_background_color(context,
 	                                       gtk_style_context_get_state(context),
 	                                       &bg);
-	snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x",
-		 (unsigned int)((fg.red + bg.red) * 0.5 * 255),
-		 (unsigned int)((fg.green + bg.green) * 0.5 * 255),
-		 (unsigned int)((fg.blue + bg.blue) * 0.5 * 255));
+	g_snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x",
+	           (unsigned int)((fg.red + bg.red) * 0.5 * 255),
+	           (unsigned int)((fg.green + bg.green) * 0.5 * 255),
+	           (unsigned int)((fg.blue + bg.blue) * 0.5 * 255));
 	return dim_grey_string;
 }
 
--- a/pidgin/libpidgin.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/pidgin/libpidgin.c	Wed Oct 30 23:25:39 2019 -0400
@@ -526,31 +526,35 @@
 	 * useful signals like SIGCHLD, so we unblock all the ones we  *
 	 * declare a handler for. thanks JSeymour and Vann.            */
 	if (sigemptyset(&sigset)) {
-		snprintf(errmsg, sizeof(errmsg), "Warning: couldn't initialise empty signal set");
+		g_snprintf(errmsg, sizeof(errmsg),
+		           "Warning: couldn't initialise empty signal set");
 		perror(errmsg);
 	}
 	for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
 		if(signal(catch_sig_list[sig_indx], sighandler) == SIG_ERR) {
-			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d for catching",
-				catch_sig_list[sig_indx]);
+			g_snprintf(errmsg, sizeof(errmsg),
+			           "Warning: couldn't set signal %d for catching",
+			           catch_sig_list[sig_indx]);
 			perror(errmsg);
 		}
 		if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
-			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't include signal %d for unblocking",
-				catch_sig_list[sig_indx]);
+			g_snprintf(errmsg, sizeof(errmsg),
+			           "Warning: couldn't include signal %d for unblocking",
+			           catch_sig_list[sig_indx]);
 			perror(errmsg);
 		}
 	}
 	for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
 		if(signal(ignore_sig_list[sig_indx], SIG_IGN) == SIG_ERR) {
-			snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d to ignore",
-				ignore_sig_list[sig_indx]);
+			g_snprintf(errmsg, sizeof(errmsg),
+			           "Warning: couldn't set signal %d to ignore",
+			           ignore_sig_list[sig_indx]);
 			perror(errmsg);
 		}
 	}
 
 	if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
-		snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals");
+		g_snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals");
 		perror(errmsg);
 	}
 }
--- a/pidgin/win32/untar.c	Wed Oct 30 22:19:59 2019 -0400
+++ b/pidgin/win32/untar.c	Wed Oct 30 23:25:39 2019 -0400
@@ -392,8 +392,8 @@
 		memset(nbuf, 0, sizeof nbuf);
 		if ((tblk)->prefix[0])
 		{
-			snprintf(nbuf, sizeof(nbuf), "%s/%s",
-				(tblk)->prefix, (tblk)->filename);
+			g_snprintf(nbuf, sizeof(nbuf), "%s/%s", (tblk)->prefix,
+			           (tblk)->filename);
 		}
 		else
 		{

mercurial