r18226 - gnucash/trunk/src - Fix more signed vs. unsigned char pointer type conflicts.
Christian Stimming
cstim at code.gnucash.org
Fri Jul 24 16:07:27 EDT 2009
Author: cstim
Date: 2009-07-24 16:07:26 -0400 (Fri, 24 Jul 2009)
New Revision: 18226
Trac: http://svn.gnucash.org/trac/changeset/18226
Modified:
gnucash/trunk/src/backend/xml/gnc-budget-xml-v2.c
gnucash/trunk/src/backend/xml/gnc-recurrence-xml-v2.c
gnucash/trunk/src/backend/xml/gnc-schedxaction-xml-v2.c
gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
gnucash/trunk/src/libqof/backend/file/qsf-xml-map.c
gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
Log:
Fix more signed vs. unsigned char pointer type conflicts.
This patch contains those cases where a cast was unavoidable.
Patch by J. Alex Aycinena. Detailed explanation follows:
1 - src/register/register-gnome/gnucash-item-edit.c
The variable 'sel' is set with 'gtk_selection_data_get_text' which
returns a 'guchar *'; 'sel' is then used by functions
'gtk_editable_insert_text' and 'strlen' which require 'gchar *', so
there is no alternative but to cast.
2 - src/backend/xml/gnc-budget-xml-v2.c
The functions 'xmlNewNode'and 'xmlSetProp' require arguments that are
of type 'const xmlChar *' but the arguments are string literals (char
*). Can string literals be set up as type 'const xmlChar *'? The
patchfile has them being cast. BAD_CAST is defined for this purpose.
3 - src/backend/xml/gnc-schedxaction-xml-v2.c
Like above, the function 'xmlNewNode' requires arguments that are of
type 'const xmlChar *' but the arguments are string literals (char *).
In the three other changes the type 'const xmlChar *' needs to be
changed to 'char *' to be used by 'strcmp'.
4 - src/backend/xml/gnc-recurrence-xml-v2.c
Like above for the functions 'xmlNewNode'and 'xmlSetProp'.
5 - src/html/gnc-html-graph-gog-webkit.c
The function 'g_base64_encode' requires type 'guchar *' for the
argument and changing the variable to this caused other problems so
used casting instead.
6 - src/libqof/backend/file/qsf-xml-map.c (6 occurances)
The first occurance was solved by changing the type declaration, but
the other 5 required casting.
Modified: gnucash/trunk/src/backend/xml/gnc-budget-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-budget-xml-v2.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/backend/xml/gnc-budget-xml-v2.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -61,8 +61,8 @@
ENTER ("(budget=%p)", bgt);
- ret = xmlNewNode(NULL, gnc_budget_string);
- xmlSetProp(ret, "version", budget_version_string);
+ ret = xmlNewNode(NULL, BAD_CAST gnc_budget_string);
+ xmlSetProp(ret, BAD_CAST "version", BAD_CAST budget_version_string);
/* field: GUID */
xmlAddChild(ret, guid_to_dom_tree(bgt_id_string,
Modified: gnucash/trunk/src/backend/xml/gnc-recurrence-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-recurrence-xml-v2.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/backend/xml/gnc-recurrence-xml-v2.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -133,8 +133,8 @@
GDate d;
WeekendAdjust wadj;
- n = xmlNewNode(NULL, tag);
- xmlSetProp(n, "version", recurrence_version_string );
+ n = xmlNewNode(NULL, BAD_CAST tag);
+ xmlSetProp(n, BAD_CAST "version", BAD_CAST recurrence_version_string );
xmlAddChild(n, guint_to_dom_tree(recurrence_mult,
recurrenceGetMultiplier(r)));
pt = recurrenceGetPeriodType(r);
Modified: gnucash/trunk/src/backend/xml/gnc-schedxaction-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-schedxaction-xml-v2.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/backend/xml/gnc-schedxaction-xml-v2.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -153,7 +153,8 @@
if (allow_2_2_incompat)
{
- xmlNodePtr schedule_node = xmlNewNode(NULL, "sx:schedule");
+ xmlNodePtr schedule_node = xmlNewNode(NULL,
+ BAD_CAST "sx:schedule");
GList *schedule = gnc_sx_get_schedule(sx);
for (; schedule != NULL; schedule = schedule->next)
{
@@ -686,7 +687,7 @@
{
xmlChar *attr_value = attr->children->content;
g_debug("sx attribute name[%s] value[%s]", attr->name, attr_value);
- if (strcmp(attr->name, "version") != 0)
+ if (strcmp((const char *)attr->name, "version") != 0)
{
g_warning("unknown sx attribute [%s]", attr->name);
continue;
@@ -694,7 +695,8 @@
// if version == 1.0.0: ensure freqspec, no recurrence
// if version == 2.0.0: ensure recurrence, no freqspec.
- if (strcmp(attr_value, schedxaction_version_string) == 0)
+ if (strcmp((const char *)attr_value,
+ schedxaction_version_string) == 0)
{
if (!sx_pdata.saw_freqspec)
g_critical("did not see freqspec in version 1 sx [%s]", sx_name);
@@ -702,7 +704,8 @@
g_warning("saw recurrence in supposedly version 1 sx [%s]", sx_name);
}
- if (strcmp(attr_value, schedxaction_version2_string) == 0)
+ if (strcmp((const char *)attr_value,
+ schedxaction_version2_string) == 0)
{
if (sx_pdata.saw_freqspec)
g_warning("saw freqspec in version 2 sx [%s]", sx_name);
Modified: gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -202,7 +202,7 @@
return NULL;
}
- base64_buf = g_base64_encode( pixel_buffer, pixel_buffer_size );
+ base64_buf = g_base64_encode( (guchar *)pixel_buffer, pixel_buffer_size );
g_free( pixel_buffer );
return base64_buf;
}
Modified: gnucash/trunk/src/libqof/backend/file/qsf-xml-map.c
===================================================================
--- gnucash/trunk/src/libqof/backend/file/qsf-xml-map.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/libqof/backend/file/qsf-xml-map.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -337,10 +337,10 @@
g_return_if_fail(params->qsf_define_hash != NULL);
iterate = NULL;
if (qsf_is_element(child, ns, MAP_DEFINE_TAG)) {
- iterate = xmlGetProp(child, MAP_ITERATE_ATTR);
+ iterate = (gchar*)xmlGetProp(child, BAD_CAST MAP_ITERATE_ATTR);
if(qof_util_bool_to_int(iterate) == 1)
{
- params->qof_foreach = xmlGetProp(child, BAD_CAST MAP_E_TYPE);
+ params->qof_foreach = (QofIdType)xmlGetProp(child, BAD_CAST MAP_E_TYPE);
}
if(NULL == g_hash_table_lookup(params->qsf_define_hash,
xmlGetProp(child, BAD_CAST MAP_E_TYPE)))
@@ -661,7 +661,8 @@
output_content = xmlNodeGetContent(param_node);
/* source refers to the source object that provides the data */
source = g_list_find_custom(params->qsf_object_list,
- BAD_CAST xmlGetProp(param_node, MAP_OBJECT_ATTR), identify_source_func);
+ BAD_CAST xmlGetProp(param_node, BAD_CAST MAP_OBJECT_ATTR),
+ identify_source_func);
if(!source) return;
params->object_set = source->data;
node = g_hash_table_lookup(params->object_set->parameters, output_content);
@@ -744,7 +745,7 @@
/* count the number of iterators in the QSF file */
if(qsf_is_element(child, ns, QSF_OBJECT_TAG))
{
- object_name = xmlGetProp(child, QSF_OBJECT_TYPE);
+ object_name = (gchar *)xmlGetProp(child, BAD_CAST QSF_OBJECT_TYPE);
if(0 == safe_strcmp(object_name, params->qof_foreach))
{
params->foreach_limit++;
@@ -793,8 +794,9 @@
params->lister = NULL;
/* cur_node describes the target object */
- if(!qof_class_is_registered(BAD_CAST
- xmlGetProp(cur_node, MAP_TYPE_ATTR))) { continue; }
+ if(!qof_class_is_registered(
+ (QofIdTypeConst)xmlGetProp(cur_node,
+ BAD_CAST MAP_TYPE_ATTR))) { continue; }
qsf_add_object_tag(params, params->count);
params->count++;
iter.ns = params->map_ns;
Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c 2009-07-24 20:07:14 UTC (rev 18225)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c 2009-07-24 20:07:26 UTC (rev 18226)
@@ -1541,7 +1541,8 @@
if (sel)
{
gtk_editable_insert_text(editable,
- sel, strlen(sel),
+ (gchar *)sel,
+ strlen((char *)sel),
&tmp_pos);
gtk_editable_set_position(editable, tmp_pos);
g_free(sel);
More information about the gnucash-changes
mailing list