g_strcmp0() only shows up on the Intarweb in documentation for some

testing version of GLib; it doesn't appear to exist in any current
versions.  There's no need to "gracefully" handle NULL (whatever
"gracefully" means in this context - NULL compares less than any real
string?), as we already checked whether mac_name is null, and we're
comparing it against a string constant; just use strcmp().

In ssh_gslist_compare_strings(), check for null pointers for now.

strcmp() (and strcmp-alikes) don't return a boolean, they return a value
such that comparing strings with a particular operator is done by
comparing the result of strcmp() with 0 using that operator; do that, to
make it clearer that the strings are being compared for equality.

svn path=/trunk/; revision=25402
This commit is contained in:
Guy Harris 2008-05-30 05:19:54 +00:00
parent ffcb641149
commit a040608bbb
1 changed files with 10 additions and 4 deletions

View File

@ -862,13 +862,13 @@ ssh_set_mac_length(struct ssh_flow_data *global_data, gchar *mac_name)
if ((size_str=g_strrstr(mac_name,"-")) && ((size=atoi(size_str+1)))) {
global_data->mac_length = size;
}
else if (!g_strcmp0(mac_name,"hmac-sha1")) {
else if (strcmp(mac_name,"hmac-sha1") == 0) {
global_data->mac_length = 20;
}
else if (!g_strcmp0(mac_name,"hmac-md5")) {
else if (strcmp(mac_name,"hmac-md5") == 0) {
global_data->mac_length = 12;
}
else if (!g_strcmp0(mac_name,"none")) {
else if (strcmp(mac_name,"none") == 0) {
global_data->mac_length = 0;
}
}
@ -876,7 +876,13 @@ ssh_set_mac_length(struct ssh_flow_data *global_data, gchar *mac_name)
static gint
ssh_gslist_compare_strings(gconstpointer a, gconstpointer b)
{
return g_strcmp0((char*)a,(char*)b);
if (a == NULL && b == NULL)
return 0;
if (a == NULL)
return -1;
if (b == NULL)
return 1;
return strcmp((char*)a,(char*)b);
}
/* expects that *result is NULL */