/pidgin/main: 512fcfb0bda3: Use more appropriate sized variables...

Mark Doliner mark at kingant.net
Fri Dec 6 03:43:10 EST 2013


Changeset: 512fcfb0bda3e4a77ae3712645d1b2cf2c01858a
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2013-12-06 00:43 -0800
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/512fcfb0bda3

Description:

Use more appropriate sized variables. Should be functionally
equivalent and performance should be basically the same. Mostly
I think the new code is more readable.

diffstat:

 libpurple/protocols/msn/msnutils.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (48 lines):

diff --git a/libpurple/protocols/msn/msnutils.c b/libpurple/protocols/msn/msnutils.c
--- a/libpurple/protocols/msn/msnutils.c
+++ b/libpurple/protocols/msn/msnutils.c
@@ -52,7 +52,6 @@ msn_parse_format(const char *mime, char 
 	char *cur;
 	GString *pre  = g_string_new(NULL);
 	GString *post = g_string_new(NULL);
-	unsigned int colors[3];
 
 	if (pre_ret  != NULL) *pre_ret  = NULL;
 	if (post_ret != NULL) *post_ret = NULL;
@@ -95,8 +94,9 @@ msn_parse_format(const char *mime, char 
 	if (cur && (*(cur = cur + 3) != ';'))
 	{
 		int i;
+		guint8 colors[3];
 
-		i = sscanf(cur, "%02x%02x%02x;", &colors[0], &colors[1], &colors[2]);
+		i = sscanf(cur, "%02hhx%02hhx%02hhx;", &colors[0], &colors[1], &colors[2]);
 
 		if (i > 0)
 		{
@@ -109,7 +109,7 @@ msn_parse_format(const char *mime, char 
 			}
 			else if (i == 2)
 			{
-				unsigned int temp = colors[0];
+				guint8 temp = colors[0];
 
 				colors[0] = colors[1];
 				colors[1] = temp;
@@ -117,14 +117,14 @@ msn_parse_format(const char *mime, char 
 			}
 			else if (i == 3)
 			{
-				unsigned int temp = colors[2];
+				guint8 temp = colors[2];
 
 				colors[2] = colors[0];
 				colors[0] = temp;
 			}
 
 			g_snprintf(tag, sizeof(tag),
-				"<FONT COLOR=\"#%02x%02x%02x\">",
+				"<FONT COLOR=\"#%02hhx%02hhx%02hhx\">",
 				colors[0] & 0xFF, colors[1] & 0xFF,
 				colors[2] & 0xFF);
 



More information about the Commits mailing list