Fix compilation warnings in filter directory (#439118).

svn path=/trunk/; revision=33624
This commit is contained in:
Matthew Barnes
2007-06-03 02:00:45 +00:00
parent 187e0c0464
commit 677df14504
12 changed files with 128 additions and 109 deletions

View File

@ -1,3 +1,22 @@
2007-05-17 Gilles Dartiguelongue <dartigug@esiee.fr>
** Fixes bug #439118
* filter-code.c: (filter_code_init):
* filter-colour.c: (xml_encode), (xml_decode):
* filter-datespec.c: (xml_encode), (xml_decode):
* filter-element.c: (xml_create):
* filter-file.c: (filter_file_new_type_name), (xml_encode),
(xml_decode):
* filter-input.c: (filter_input_new_type_name), (xml_encode),
(xml_decode):
* filter-int.c: (xml_encode), (xml_decode):
* filter-option.c: (xml_create), (xml_encode), (xml_decode):
* filter-part.c: (filter_part_xml_create),
(filter_part_xml_encode), (filter_part_xml_decode):
* filter-rule.c: (xml_encode), (load_set), (xml_decode):
* rule-context.c: (load), (save), (revert): fix compilation warnings
2007-05-11 Srinivasa Ragavan <sragavan@novell.com>
** Patch from Trever Adams for bug #211058

View File

@ -80,7 +80,7 @@ filter_code_class_init (FilterCodeClass *klass)
static void
filter_code_init (FilterCode *fc)
{
((FilterInput *) fc)->type = xmlStrdup ("code");
((FilterInput *) fc)->type = (char *)xmlStrdup ((const unsigned char *)"code");
}
static void

View File

@ -144,10 +144,10 @@ xml_encode (FilterElement *fe)
g_snprintf (spec, sizeof (spec), "#%04x%04x%04x",
fc->color.red, fc->color.green, fc->color.blue);
value = xmlNewNode(NULL, "value");
xmlSetProp(value, "name", fe->name);
xmlSetProp(value, "type", "colour");
xmlSetProp(value, "spec", spec);
value = xmlNewNode(NULL, (const unsigned char *)"value");
xmlSetProp(value, (const unsigned char *)"type", (const unsigned char *)"colour");
xmlSetProp(value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp(value, (const unsigned char *)"spec", (unsigned char *)spec);
return value;
}
@ -159,22 +159,22 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
xmlChar *prop;
xmlFree (fe->name);
fe->name = xmlGetProp(node, "name");
fe->name = (char *)xmlGetProp(node, (const unsigned char *)"name");
prop = xmlGetProp(node, "spec");
prop = xmlGetProp(node, (const unsigned char *)"spec");
if (prop != NULL) {
gdk_color_parse(prop, &fc->color);
gdk_color_parse((char *)prop, &fc->color);
xmlFree (prop);
} else {
/* try reading the old RGB properties */
prop = xmlGetProp(node, "red");
sscanf(prop, "%" G_GINT16_MODIFIER "x", &fc->color.red);
prop = xmlGetProp(node, (const unsigned char *)"red");
sscanf((char *)prop, "%" G_GINT16_MODIFIER "x", &fc->color.red);
xmlFree (prop);
prop = xmlGetProp(node, "green");
sscanf(prop, "%" G_GINT16_MODIFIER "x", &fc->color.green);
prop = xmlGetProp(node, (const unsigned char *)"green");
sscanf((char *)prop, "%" G_GINT16_MODIFIER "x", &fc->color.green);
xmlFree (prop);
prop = xmlGetProp(node, "blue");
sscanf(prop, "%" G_GINT16_MODIFIER "x", &fc->color.blue);
prop = xmlGetProp(node, (const unsigned char *)"blue");
sscanf((char *)prop, "%" G_GINT16_MODIFIER "x", &fc->color.blue);
xmlFree (prop);
}

View File

@ -220,15 +220,15 @@ xml_encode (FilterElement *fe)
d(printf ("Encoding datespec as xml\n"));
value = xmlNewNode (NULL, "value");
xmlSetProp (value, "name", fe->name);
xmlSetProp (value, "type", "datespec");
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (const unsigned char *)"datespec");
work = xmlNewChild (value, NULL, "datespec", NULL);
work = xmlNewChild (value, NULL, (const unsigned char *)"datespec", NULL);
sprintf (str, "%d", fds->type);
xmlSetProp (work, "type", str);
xmlSetProp (work, (const unsigned char *)"type", (unsigned char *)str);
sprintf (str, "%d", (int)fds->value);
xmlSetProp (work, "value", str);
xmlSetProp (work, (const unsigned char *)"value", (unsigned char *)str);
return value;
}
@ -238,21 +238,21 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
{
FilterDatespec *fds = (FilterDatespec *)fe;
xmlNodePtr n;
char *val;
xmlChar *val;
d(printf ("Decoding datespec from xml %p\n", fe));
xmlFree (fe->name);
fe->name = xmlGetProp (node, "name");
fe->name = (char *)xmlGetProp (node, (const unsigned char *)"name");
n = node->children;
while (n) {
if (!strcmp (n->name, "datespec")) {
val = xmlGetProp (n, "type");
fds->type = atoi (val);
if (!strcmp ((char *)n->name, "datespec")) {
val = xmlGetProp (n, (const unsigned char *)"type");
fds->type = atoi ((char *)val);
xmlFree (val);
val = xmlGetProp (n, "value");
fds->value = atoi (val);
val = xmlGetProp (n, (const unsigned char *)"value");
fds->value = atoi ((char *)val);
xmlFree (val);
break;
}

View File

@ -254,7 +254,7 @@ element_eq (FilterElement *fe, FilterElement *cm)
static void
xml_create (FilterElement *fe, xmlNodePtr node)
{
fe->name = xmlGetProp (node, "name");
fe->name = (char *)xmlGetProp (node, (const unsigned char *)"name");
}
static FilterElement *

View File

@ -140,7 +140,7 @@ filter_file_new_type_name (const char *type)
FilterFile *file;
file = filter_file_new ();
file->type = xmlStrdup (type);
file->type = (char *)xmlStrdup ((xmlChar *)type);
return file;
}
@ -218,12 +218,12 @@ xml_encode (FilterElement *fe)
d(printf ("Encoding %s as xml\n", type));
value = xmlNewNode (NULL, "value");
xmlSetProp (value, "name", fe->name);
xmlSetProp (value, "type", type);
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (unsigned char *)type);
cur = xmlNewChild (value, NULL, type, NULL);
xmlNodeSetContent (cur, file->path);
cur = xmlNewChild (value, NULL, (unsigned char *)type, NULL);
xmlNodeSetContent (cur, (unsigned char *)file->path);
return value;
}
@ -235,8 +235,8 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
char *name, *str, *type;
xmlNodePtr n;
name = xmlGetProp (node, "name");
type = xmlGetProp (node, "type");
name = (char *)xmlGetProp (node, (const unsigned char *)"name");
type = (char *)xmlGetProp (node, (const unsigned char *)"type");
d(printf("Decoding %s from xml %p\n", type, fe));
d(printf ("Name = %s\n", name));
@ -251,8 +251,8 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
n = node->children;
while (n != NULL) {
if (!strcmp (n->name, type)) {
str = xmlNodeGetContent (n);
if (!strcmp ((char *)n->name, type)) {
str = (char *)xmlNodeGetContent (n);
file->path = g_strdup (str ? str : "");
xmlFree (str);

View File

@ -137,7 +137,7 @@ filter_input_new_type_name (const char *type)
FilterInput *fi;
fi = filter_input_new ();
fi->type = xmlStrdup (type);
fi->type = (char *)xmlStrdup ((xmlChar *)type);
d(printf("new type %s = %p\n", type, fi));
@ -243,15 +243,15 @@ xml_encode (FilterElement *fe)
d(printf ("Encoding %s as xml\n", type));
value = xmlNewNode (NULL, "value");
xmlSetProp (value, "name", fe->name);
xmlSetProp (value, "type", type);
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (unsigned char *)type);
l = fi->values;
while (l) {
xmlNodePtr cur;
char *str = l->data;
xmlChar *str = l->data;
cur = xmlNewChild (value, NULL, type, NULL);
cur = xmlNewChild (value, NULL, (unsigned char *)type, NULL);
str = xmlEncodeEntitiesReentrant (NULL, str);
xmlNodeSetContent (cur, str);
@ -279,8 +279,8 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
g_list_free (fi->values);
fi->values = NULL;
name = xmlGetProp (node, "name");
type = xmlGetProp (node, "type");
name = (char *)xmlGetProp (node, (const unsigned char *)"name");
type = (char *)xmlGetProp (node, (const unsigned char *)"type");
d(printf("Decoding %s from xml %p\n", type, fe));
d(printf ("Name = %s\n", name));
@ -290,9 +290,9 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
fi->type = type;
n = node->children;
while (n) {
if (!strcmp (n->name, type)) {
if (!(str = xmlNodeGetContent (n)))
str = xmlStrdup ("");
if (!strcmp ((char *)n->name, type)) {
if (!(str = (char *)xmlNodeGetContent (n)))
str = (char *)xmlStrdup ((const unsigned char *)"");
d(printf (" '%s'\n", str));
fi->values = g_list_append (fi->values, g_strdup (str));

View File

@ -184,12 +184,12 @@ xml_encode (FilterElement *fe)
d(printf("Encoding %s as xml\n", type));
value = xmlNewNode (NULL, "value");
xmlSetProp (value, "name", fe->name);
xmlSetProp (value, "type", type);
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (unsigned char *)type);
sprintf(intval, "%d", fs->val);
xmlSetProp (value, type, intval);
xmlSetProp (value, (unsigned char *)type, (unsigned char *)intval);
return value;
}
@ -203,18 +203,18 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
d(printf("Decoding integer from xml %p\n", fe));
name = xmlGetProp (node, "name");
name = (char *)xmlGetProp (node, (const unsigned char *)"name");
d(printf ("Name = %s\n", name));
xmlFree (fe->name);
fe->name = name;
type = xmlGetProp(node, "type");
type = (char *)xmlGetProp(node, (const unsigned char *)"type");
d(printf ("Type = %s\n", type));
g_free(fs->type);
fs->type = g_strdup(type);
xmlFree(type);
intval = xmlGetProp (node, fs->type ? fs->type : "integer");
intval = (char *)xmlGetProp (node, (unsigned char *)(fs->type ? fs->type : "integer"));
if (intval) {
d(printf ("Value = %s\n", intval));
fs->val = atoi (intval);

View File

@ -204,24 +204,24 @@ xml_create (FilterElement *fe, xmlNodePtr node)
n = node->children;
while (n) {
if (!strcmp (n->name, "option")) {
if (!strcmp ((char *)n->name, "option")) {
char *tmp, *value, *title = NULL, *code = NULL;
value = xmlGetProp (n, "value");
value = (char *)xmlGetProp (n, (const unsigned char *)"value");
work = n->children;
while (work) {
if (!strcmp (work->name, "title")) {
if (!strcmp ((char *)work->name, "title")) {
if (!title) {
if (!(tmp = xmlNodeGetContent (work)))
tmp = xmlStrdup ("");
if (!(tmp = (char *)xmlNodeGetContent (work)))
tmp = (char *)xmlStrdup ((const unsigned char *)"");
title = g_strdup (tmp);
xmlFree (tmp);
}
} else if (!strcmp (work->name, "code")) {
} else if (!strcmp ((char *)work->name, "code")) {
if (!code) {
if (!(tmp = xmlNodeGetContent (work)))
tmp = xmlStrdup ("");
if (!(tmp = (char*)xmlNodeGetContent (work)))
tmp = (char *)xmlStrdup ((const unsigned char *)"");
code = g_strdup (tmp);
xmlFree (tmp);
@ -248,11 +248,11 @@ xml_encode (FilterElement *fe)
FilterOption *fo = (FilterOption *)fe;
d(printf ("Encoding option as xml\n"));
value = xmlNewNode (NULL, "value");
xmlSetProp (value, "name", fe->name);
xmlSetProp (value, "type", fo->type);
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (unsigned char *)fo->type);
if (fo->current)
xmlSetProp (value, "value", fo->current->value);
xmlSetProp (value, (const unsigned char *)"value", (unsigned char *)fo->current->value);
return value;
}
@ -265,8 +265,8 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
d(printf ("Decoding option from xml\n"));
xmlFree (fe->name);
fe->name = xmlGetProp (node, "name");
value = xmlGetProp (node, "value");
fe->name = (char *)xmlGetProp (node, (const unsigned char *)"name");
value = (char *)xmlGetProp (node, (const unsigned char *)"value");
if (value) {
fo->current = find_option (fo, value);
xmlFree (value);

View File

@ -170,15 +170,15 @@ filter_part_xml_create (FilterPart *ff, xmlNodePtr node, RuleContext *rc)
char *type, *str;
FilterElement *el;
str = xmlGetProp (node, "name");
str = (char *)xmlGetProp (node, (const unsigned char *)"name");
ff->name = g_strdup (str);
if (str)
xmlFree (str);
n = node->children;
while (n) {
if (!strcmp (n->name, "input")) {
type = xmlGetProp (n, "type");
if (!strcmp ((char *)n->name, "input")) {
type = (char *)xmlGetProp (n, (const unsigned char *)"type");
d(printf ("creating new element type input '%s'\n", type));
if (type != NULL
&& (el = rule_context_new_element(rc, type)) != NULL) {
@ -189,16 +189,16 @@ filter_part_xml_create (FilterPart *ff, xmlNodePtr node, RuleContext *rc)
} else {
g_warning ("Invalid xml format, missing/unknown input type");
}
} else if (!strcmp (n->name, "title")) {
} else if (!strcmp ((char *)n->name, "title")) {
if (!ff->title) {
str = xmlNodeGetContent (n);
str = (char *)xmlNodeGetContent (n);
ff->title = g_strdup (str);
if (str)
xmlFree (str);
}
} else if (!strcmp (n->name, "code")) {
} else if (!strcmp ((char *)n->name, "code")) {
if (!ff->code) {
str = xmlNodeGetContent (n);
str = (char *)xmlNodeGetContent (n);
ff->code = g_strdup (str);
if (str)
xmlFree (str);
@ -221,8 +221,8 @@ filter_part_xml_encode (FilterPart *fp)
g_return_val_if_fail (fp != NULL, NULL);
part = xmlNewNode (NULL, "part");
xmlSetProp (part, "name", fp->name);
part = xmlNewNode (NULL, (const unsigned char *)"part");
xmlSetProp (part, (const unsigned char *)"name", (unsigned char *)fp->name);
l = fp->elements;
while (l) {
fe = l->data;
@ -247,8 +247,8 @@ filter_part_xml_decode (FilterPart *fp, xmlNodePtr node)
n = node->children;
while (n) {
if (!strcmp (n->name, "value")) {
name = xmlGetProp (n, "name");
if (!strcmp ((char *)n->name, "value")) {
name = (char *)xmlGetProp (n, (const unsigned char *)"name");
d(printf ("finding element part %p %s = %p\n", name, name, fe));
fe = filter_part_find_element (fp, name);
d(printf ("finding element part %p %s = %p\n", name, name, fe));

View File

@ -280,13 +280,13 @@ xml_encode (FilterRule *fr)
xmlNodePtr node, set, work;
GList *l;
node = xmlNewNode (NULL, "rule");
node = xmlNewNode (NULL, (const unsigned char *)"rule");
switch (fr->grouping) {
case FILTER_GROUP_ALL:
xmlSetProp (node, "grouping", "all");
xmlSetProp (node, (const unsigned char *)"grouping", (const unsigned char *)"all");
break;
case FILTER_GROUP_ANY:
xmlSetProp (node, "grouping", "any");
xmlSetProp (node, (const unsigned char *)"grouping", (const unsigned char *)"any");
break;
}
@ -294,33 +294,33 @@ xml_encode (FilterRule *fr)
case FILTER_THREAD_NONE:
break;
case FILTER_THREAD_ALL:
xmlSetProp(node, "threading", "all");
xmlSetProp(node, (const unsigned char *)"threading", (const unsigned char *)"all");
break;
case FILTER_THREAD_REPLIES:
xmlSetProp(node, "threading", "replies");
xmlSetProp(node, (const unsigned char *)"threading", (const unsigned char *)"replies");
break;
case FILTER_THREAD_REPLIES_PARENTS:
xmlSetProp(node, "threading", "replies_parents");
xmlSetProp(node, (const unsigned char *)"threading", (const unsigned char *)"replies_parents");
break;
case FILTER_THREAD_SINGLE:
xmlSetProp(node, "threading", "single");
xmlSetProp(node, (const unsigned char *)"threading", (const unsigned char *)"single");
break;
}
if (fr->source) {
xmlSetProp (node, "source", fr->source);
xmlSetProp (node, (const unsigned char *)"source", (unsigned char *)fr->source);
} else {
/* set to the default filter type */
xmlSetProp (node, "source", "incoming");
xmlSetProp (node, (const unsigned char *)"source", (const unsigned char *)"incoming");
}
if (fr->name) {
work = xmlNewNode (NULL, "title");
xmlNodeSetContent (work, fr->name);
work = xmlNewNode (NULL, (const unsigned char *)"title");
xmlNodeSetContent (work, (unsigned char *)fr->name);
xmlAddChild (node, work);
}
set = xmlNewNode (NULL, "partset");
set = xmlNewNode (NULL, (const unsigned char *)"partset");
xmlAddChild (node, set);
l = fr->parts;
while (l) {
@ -341,8 +341,8 @@ load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f)
work = node->children;
while (work) {
if (!strcmp (work->name, "part")) {
rulename = xmlGetProp (work, "name");
if (!strcmp ((char *)work->name, "part")) {
rulename = (char *)xmlGetProp (work, (const unsigned char *)"name");
part = rule_context_find_part (f, rulename);
if (part) {
part = filter_part_clone (part);
@ -389,7 +389,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
fr->name = NULL;
}
grouping = xmlGetProp (node, "grouping");
grouping = (char *)xmlGetProp (node, (const unsigned char *)"grouping");
if (!strcmp (grouping, "any"))
fr->grouping = FILTER_GROUP_ANY;
else
@ -398,7 +398,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
fr->threading = FILTER_THREAD_NONE;
if (f->flags & RULE_CONTEXT_THREADING
&& (grouping = xmlGetProp (node, "threading"))) {
&& (grouping = (char *)xmlGetProp (node, (const unsigned char *)"threading"))) {
if (!strcmp(grouping, "all"))
fr->threading = FILTER_THREAD_ALL;
else if (!strcmp(grouping, "replies"))
@ -411,7 +411,7 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
}
g_free (fr->source);
source = xmlGetProp (node, "source");
source = (char *)xmlGetProp (node, (const unsigned char *)"source");
if (source) {
fr->source = g_strdup (source);
xmlFree (source);
@ -422,13 +422,13 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
work = node->children;
while (work) {
if (!strcmp (work->name, "partset")) {
if (!strcmp ((char *)work->name, "partset")) {
load_set (work, fr, f);
} else if (!strcmp (work->name, "title") || !strcmp (work->name, "_title")) {
} else if (!strcmp ((char *)work->name, "title") || !strcmp ((char *)work->name, "_title")) {
if (!fr->name) {
char *str, *decstr;
str = xmlNodeGetContent (work);
str = (char *)xmlNodeGetContent (work);
decstr = g_strdup (str);
if (str)
xmlFree (str);

View File

@ -317,7 +317,7 @@ load(RuleContext *rc, const char *system, const char *user)
}
root = xmlDocGetRootElement(systemdoc);
if (root == NULL || strcmp(root->name, "filterdescription")) {
if (root == NULL || strcmp((char *)root->name, "filterdescription")) {
rule_context_set_error(rc, g_strdup_printf("Unable to load system rules '%s': Invalid format", system));
xmlFreeDoc(systemdoc);
return -1;
@ -337,7 +337,7 @@ load(RuleContext *rc, const char *system, const char *user)
d(printf("loading parts ...\n"));
rule = set->children;
while (rule) {
if (!strcmp(rule->name, "part")) {
if (!strcmp((char *)rule->name, "part")) {
FilterPart *part = FILTER_PART(g_object_new(part_map->type, NULL, NULL));
if (filter_part_xml_create(part, rule, rc) == 0) {
@ -354,7 +354,7 @@ load(RuleContext *rc, const char *system, const char *user)
rule = set->children;
while (rule) {
d(printf("checking node: %s\n", rule->name));
if (!strcmp(rule->name, "rule")) {
if (!strcmp((char *)rule->name, "rule")) {
FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL));
if (filter_rule_xml_decode(part, rule, rc) == 0) {
@ -383,7 +383,7 @@ load(RuleContext *rc, const char *system, const char *user)
rule = set->children;
while (rule) {
d(printf("checking node: %s\n", rule->name));
if (!strcmp(rule->name, "rule")) {
if (!strcmp((char *)rule->name, "rule")) {
FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL));
if (filter_rule_xml_decode(part, rule, rc) == 0) {
@ -434,14 +434,14 @@ save(RuleContext *rc, const char *user)
struct _rule_set_map *map;
int ret;
doc = xmlNewDoc("1.0");
doc = xmlNewDoc((const unsigned char *)"1.0");
/* FIXME: set character encoding to UTF-8? */
root = xmlNewDocNode(doc, NULL, "filteroptions", NULL);
root = xmlNewDocNode(doc, NULL, (const unsigned char *)"filteroptions", NULL);
xmlDocSetRootElement(doc, root);
l = rc->rule_set_list;
while (l) {
map = l->data;
rules = xmlNewDocNode(doc, NULL, map->name, NULL);
rules = xmlNewDocNode(doc, NULL, (unsigned char *)map->name, NULL);
xmlAddChild(root, rules);
rule = NULL;
while ((rule = map->next(rc, rule, NULL))) {
@ -563,7 +563,7 @@ revert(RuleContext *rc, const char *user)
rule = set->children;
while (rule) {
d(printf("checking node: %s\n", rule->name));
if (!strcmp(rule->name, "rule")) {
if (!strcmp((char *)rule->name, "rule")) {
FilterRule *part = FILTER_RULE(g_object_new(rule_map->type, NULL, NULL));
if (filter_rule_xml_decode(part, rule, rc) == 0) {