[tracker: 3/5] libtracker-sparql: Solve signed vs unsigned pointer warnings
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 3/5] libtracker-sparql: Solve signed vs unsigned pointer warnings
- Date: Sat, 8 May 2021 16:19:01 +0000 (UTC)
commit 7b58c3f7aa952811df4406a368372d2a078da153
Author: Daniele Nicolodi <daniele grinta net>
Date: Thu May 6 13:37:37 2021 +0200
libtracker-sparql: Solve signed vs unsigned pointer warnings
libxml2 functions 'const xmlChar *' (aka 'unsigned char *') type for
strings arguments however literals in C are of type 'char *'. This
results in warnings about the conversion between pointers of different
size. Add a macro to perform the type casts required to silence the
warnings in a more descriptive and less ugly way.
src/libtracker-sparql/tracker-serializer-xml.c | 27 ++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-serializer-xml.c b/src/libtracker-sparql/tracker-serializer-xml.c
index a722809bd..d2b66f83b 100644
--- a/src/libtracker-sparql/tracker-serializer-xml.c
+++ b/src/libtracker-sparql/tracker-serializer-xml.c
@@ -29,6 +29,9 @@
#include <libxml/xmlwriter.h>
+/* Make required type casts a bit more descriptive. */
+#define XML(x) ((const xmlChar *) x)
+
struct _TrackerSerializerXml
{
TrackerSerializer parent_instance;
@@ -75,15 +78,15 @@ serialize_up_to_position (TrackerSerializerXml *serializer_xml,
if (!serializer_xml->head_printed) {
xmlTextWriterStartDocument (serializer_xml->writer, "1.0", "UTF-8", NULL);
- xmlTextWriterStartElement (serializer_xml->writer, "sparql");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("sparql"));
- xmlTextWriterStartElement (serializer_xml->writer, "head");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("head"));
for (i = 0; i < tracker_sparql_cursor_get_n_columns (cursor); i++) {
const gchar *var;
var = tracker_sparql_cursor_get_variable_name (cursor, i);
- xmlTextWriterStartElement (serializer_xml->writer, "variable");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("variable"));
if (var && *var) {
g_ptr_array_add (serializer_xml->vars,
@@ -94,14 +97,14 @@ serialize_up_to_position (TrackerSerializerXml *serializer_xml,
}
xmlTextWriterWriteFormatAttribute (serializer_xml->writer,
- "name",
+ XML ("name"),
"%s",
- (gchar *) g_ptr_array_index (serializer_xml->vars,
i));
+ g_ptr_array_index (serializer_xml->vars, i));
xmlTextWriterEndElement (serializer_xml->writer);
}
xmlTextWriterEndElement (serializer_xml->writer);
- xmlTextWriterStartElement (serializer_xml->writer, "results");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("results"));
serializer_xml->head_printed = TRUE;
}
@@ -122,7 +125,7 @@ serialize_up_to_position (TrackerSerializerXml *serializer_xml,
serializer_xml->cursor_started = TRUE;
}
- xmlTextWriterStartElement (serializer_xml->writer, "result");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("result"));
for (i = 0; i < tracker_sparql_cursor_get_n_columns (cursor); i++) {
const gchar *var, *str, *type = NULL, *datatype = NULL;
@@ -157,17 +160,17 @@ serialize_up_to_position (TrackerSerializerXml *serializer_xml,
var = g_ptr_array_index (serializer_xml->vars, i);
- xmlTextWriterStartElement (serializer_xml->writer, "binding");
+ xmlTextWriterStartElement (serializer_xml->writer, XML ("binding"));
xmlTextWriterWriteFormatAttribute (serializer_xml->writer,
- "name",
+ XML ("name"),
"%s",
var);
- xmlTextWriterStartElement (serializer_xml->writer, type);
+ xmlTextWriterStartElement (serializer_xml->writer, XML (type));
if (datatype) {
xmlTextWriterWriteFormatAttribute (serializer_xml->writer,
- "datatype",
+ XML ("datatype"),
"%s",
datatype);
}
@@ -175,7 +178,7 @@ serialize_up_to_position (TrackerSerializerXml *serializer_xml,
str = tracker_sparql_cursor_get_string (cursor, i, NULL);
if (str) {
- xmlTextWriterWriteRaw (serializer_xml->writer, str);
+ xmlTextWriterWriteRaw (serializer_xml->writer, XML (str));
}
xmlTextWriterEndElement (serializer_xml->writer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]