changeset 20767:d91c76c76da8

Sanity checking and minor cleanup.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 04 Oct 2007 01:09:10 +0000
parents 5beeb2e546c2
children 48ee7ec3426d
files libpurple/protocols/msn/command.c
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/command.c	Thu Oct 04 01:07:35 2007 +0000
+++ b/libpurple/protocols/msn/command.c	Thu Oct 04 01:09:10 2007 +0000
@@ -25,9 +25,9 @@
 #include "command.h"
 
 static gboolean
-is_num(char *str)
+is_num(const char *str)
 {
-	char *c;
+	const char *c;
 	for (c = str; *c; c++) {
 		if (!(g_ascii_isdigit(*c)))
 			return FALSE;
@@ -42,9 +42,11 @@
  *  else 		return FALSE
  */
 static gboolean
-msn_check_payload_cmd(char *str)
+msn_check_payload_cmd(const char *str)
 {
-	if( (!strcmp(str,"ADL")) ||
+	g_return_val_if_fail(str != NULL, FALSE);
+
+	if((!strcmp(str,"ADL")) ||
 		(!strcmp(str,"GCF")) ||
 		(!strcmp(str,"SG")) ||
 		(!strcmp(str,"MSG")) ||
@@ -84,16 +86,13 @@
 msn_command_from_string(const char *string)
 {
 	MsnCommand *cmd;
-	char *tmp;
 	char *param_start;
 
 	g_return_val_if_fail(string != NULL, NULL);
 
-	tmp = g_strdup(string);
-	param_start = strchr(tmp, ' ');
-
 	cmd = g_new0(MsnCommand, 1);
-	cmd->command = tmp;
+	cmd->command = g_strdup(string);
+	param_start = strchr(cmd->command, ' ');
 
 	if (param_start)
 	{