changeset 32365:e8d4755ef84b

Don't use strlen() when you're just checking whether a string is empty
author Mark Doliner <mark@kingant.net>
date Mon, 22 Aug 2011 02:11:36 +0000
parents 323876c34a96
children 99ca503ea087
files libpurple/protocols/gg/buddylist.c libpurple/protocols/mxit/login.c libpurple/protocols/mxit/profile.c libpurple/protocols/mxit/voicevideo.c libpurple/protocols/null/nullprpl.c libpurple/protocols/zephyr/zephyr.c pidgin/gtkconv.c
diffstat 7 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/buddylist.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/gg/buddylist.c	Mon Aug 22 02:11:36 2011 +0000
@@ -90,7 +90,7 @@
 		gchar **data_tbl;
 		gchar *name, *show, *g;
 
-		if (strlen(users_tbl[i]) == 0)
+		if (!*users_tbl[i])
 			continue;
 
 		data_tbl = g_strsplit(users_tbl[i], ";", 8);
--- a/libpurple/protocols/mxit/login.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/mxit/login.c	Mon Aug 22 02:11:36 2011 +0000
@@ -743,7 +743,7 @@
 	 * if we don't have any info saved from a previous login, we need to get it from the MXit WAP site.
 	 * we do cache it, so this step is only done on the very first login for each account.
 	 */
-	if ( ( session->distcode == NULL ) || ( strlen( session->distcode ) == 0 ) ) {
+	if ( ( session->distcode == NULL ) || ( !*session->distcode ) ) {
 		/* this must be the very first login, so we need to retrieve the user information */
 		get_clientinfo( session );
 	}
--- a/libpurple/protocols/mxit/profile.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/mxit/profile.c	Mon Aug 22 02:11:36 2011 +0000
@@ -115,7 +115,7 @@
 	struct tm now, bdate;
 	int age;
 
-	if ( ( !date ) || ( strlen( date ) == 0 ) )
+	if ( ( !date ) || ( !*date ) )
 		return 0;
 
 	/* current time */
--- a/libpurple/protocols/mxit/voicevideo.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/mxit/voicevideo.c	Mon Aug 22 02:11:36 2011 +0000
@@ -71,7 +71,7 @@
 	purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_caps: buddy '%s'\n", who);
 
 	/* We need to have a voice/video server */
-	if (strlen(session->voip_server) == 0)
+	if (!*session->voip_server)
 		return PURPLE_MEDIA_CAPS_NONE;
 
 	/* find the buddy information for this contact (reference: "libpurple/blist.h") */
--- a/libpurple/protocols/null/nullprpl.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/null/nullprpl.c	Mon Aug 22 02:11:36 2011 +0000
@@ -781,10 +781,10 @@
   to_username = args[0];
   message = args[1];
 
-  if (!to_username || strlen(to_username) == 0) {
+  if (!to_username || !*to_username) {
     *error = g_strdup(_("Whisper is missing recipient."));
     return PURPLE_CMD_RET_FAILED;
-  } else if (!message || strlen(message) == 0) {
+  } else if (!message || !*message) {
     *error = g_strdup(_("Whisper is missing message."));
     return PURPLE_CMD_RET_FAILED;
   }
--- a/libpurple/protocols/zephyr/zephyr.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/libpurple/protocols/zephyr/zephyr.c	Mon Aug 22 02:11:36 2011 +0000
@@ -1164,7 +1164,7 @@
 				locations = find_node(newparsetree,"locations");
 				locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents;
 
-				if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) {
+				if (!locval || !g_ascii_strcasecmp(locval," ") || !*locval) {
 					nlocs = 0;
 				} else {
 					nlocs = 1;
--- a/pidgin/gtkconv.c	Mon Aug 22 02:07:41 2011 +0000
+++ b/pidgin/gtkconv.c	Mon Aug 22 02:11:36 2011 +0000
@@ -578,7 +578,7 @@
 
 	gtk_widget_grab_focus(gtkconv->entry);
 
-	if (strlen(clean) == 0) {
+	if (!*clean) {
 		g_free(buf);
 		g_free(clean);
 		return;