shell-app-usage: Fix several problems in xml parsing
Coverity rightly complained about the context < 0 comparison. In addition, context was shadowing the parameter of the same name, and the loops over the attributes were unnecessarily running all the way. https://bugzilla.gnome.org/show_bug.cgi?id=689325
This commit is contained in:
parent
98f4b99446
commit
716d7bb93e
@ -785,16 +785,19 @@ shell_app_usage_start_element_handler (GMarkupParseContext *context,
|
|||||||
}
|
}
|
||||||
else if (strcmp (element_name, "context") == 0)
|
else if (strcmp (element_name, "context") == 0)
|
||||||
{
|
{
|
||||||
char *context = NULL;
|
char *id = NULL;
|
||||||
const char **attribute;
|
const char **attribute;
|
||||||
const char **value;
|
const char **value;
|
||||||
|
|
||||||
for (attribute = attribute_names, value = attribute_values; *attribute; attribute++, value++)
|
for (attribute = attribute_names, value = attribute_values; *attribute; attribute++, value++)
|
||||||
{
|
{
|
||||||
if (strcmp (*attribute, "id") == 0)
|
if (strcmp (*attribute, "id") == 0)
|
||||||
context = g_strdup (*value);
|
{
|
||||||
|
id = g_strdup (*value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (context < 0)
|
}
|
||||||
|
if (!id)
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_MARKUP_ERROR,
|
G_MARKUP_ERROR,
|
||||||
@ -803,7 +806,7 @@ shell_app_usage_start_element_handler (GMarkupParseContext *context,
|
|||||||
element_name);
|
element_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data->context = context;
|
data->context = id;
|
||||||
}
|
}
|
||||||
else if (strcmp (element_name, "application") == 0)
|
else if (strcmp (element_name, "application") == 0)
|
||||||
{
|
{
|
||||||
@ -816,7 +819,10 @@ shell_app_usage_start_element_handler (GMarkupParseContext *context,
|
|||||||
for (attribute = attribute_names, value = attribute_values; *attribute; attribute++, value++)
|
for (attribute = attribute_names, value = attribute_values; *attribute; attribute++, value++)
|
||||||
{
|
{
|
||||||
if (strcmp (*attribute, "id") == 0)
|
if (strcmp (*attribute, "id") == 0)
|
||||||
|
{
|
||||||
appid = g_strdup (*value);
|
appid = g_strdup (*value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appid)
|
if (!appid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user