diff options
author | Pablo Correa Gómez <ablocorrea@hotmail.com> | 2022-10-28 01:22:17 +0200 |
---|---|---|
committer | Pablo Correa Gómez <ablocorrea@hotmail.com> | 2022-10-28 01:28:45 +0200 |
commit | 39b6b88bf82e4fd390a86e4fe2cc9c8333f04c69 (patch) | |
tree | 073ebdb4a221e71ef442ba73c0e314eb066828ce | |
parent | bec3d2f26de1b3a8c8b7e603f6d6a46c853426fa (diff) | |
download | gnome-maps-39b6b88bf82e4fd390a86e4fe2cc9c8333f04c69.tar.gz |
maps-osm: Fix g_str_equal warnings from GLib >= 2.74
GLib 2.74 introduced an optimization for string comparison[1], but
that generates warnings similar to the following:
In file included from /usr/include/glib-2.0/glib.h:52,
from ../lib/maps-osm.h:23,
from ../lib/maps-osm.c:20:
../lib/maps-osm.c: In function 'parse_tag':
../lib/maps-osm.c:75:32: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness [-Wpointer-sign]
75 | if (g_str_equal (cur_attr->name, "k"))
/usr/include/glib-2.0/glib/ghash.h:165:39: note: in definition of macro 'g_str_equal'
165 | #define g_str_equal(v1, v2) (strcmp ((v1), (v2)) == 0)
| ^~
In file included from /usr/include/fortify/string.h:22,
from /usr/include/glib-2.0/glib/galloca.h:35,
from /usr/include/glib-2.0/glib.h:32:
/usr/include/string.h:39:13: note: expected 'const char *' but argument is of type 'const xmlChar *' {aka 'const unsigned char *'}
39 | int strcmp (const char *, const char *);
| ^~~~~~~~~~~~
Silence the warnings by casting the pointers to the correct type
[1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2940
-rw-r--r-- | lib/maps-osm.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/maps-osm.c b/lib/maps-osm.c index da03ffed..910c8782 100644 --- a/lib/maps-osm.c +++ b/lib/maps-osm.c @@ -69,12 +69,12 @@ parse_tag (const xmlAttr *attrs, GHashTable *tags) key = NULL; value = NULL; - + for (cur_attr = attrs; cur_attr; cur_attr = cur_attr->next) { - if (g_str_equal (cur_attr->name, "k")) + if (g_str_equal ((const char *) cur_attr->name, "k")) key = (char *) cur_attr->children->content; - else if (g_str_equal (cur_attr->name, "v")) + else if (g_str_equal ((const char *) cur_attr->name, "v")) value = (char *) cur_attr->children->content; else g_warning ("Unexpected tag property: %s\n", cur_attr->name); @@ -115,7 +115,7 @@ parse_tags (const xmlNode *tag_child) if (cur_node->type != XML_ELEMENT_NODE) continue; - if (g_str_equal (cur_node->name, "tag")) + if (g_str_equal ((const char *) cur_node->name, "tag")) parse_tag (cur_node->properties, tags); } @@ -136,7 +136,7 @@ parse_node_refs (const xmlNode *node_ref_child) if (cur_node->type != XML_ELEMENT_NODE) continue; - if (g_str_equal (cur_node->name, "nd")) + if (g_str_equal ((const char *) cur_node->name, "nd")) { char *ref; GHashTable *attributes; @@ -332,7 +332,7 @@ parse_members (const xmlNode *member_child) if (cur_node->type != XML_ELEMENT_NODE) continue; - if (g_str_equal (cur_node->name, "member")) + if (g_str_equal ((const char *) cur_node->name, "member")) { GHashTable *attributes; @@ -452,15 +452,15 @@ maps_osm_parse (const char *content, guint length, GError **error) return NULL; } - if (g_str_equal (sub_node->name, "node")) + if (g_str_equal ((const char *) sub_node->name, "node")) { object = MAPS_OSMOBJECT (parse_node (sub_node, error)); } - else if (g_str_equal (sub_node->name, "way")) + else if (g_str_equal ((const char *) sub_node->name, "way")) { object = MAPS_OSMOBJECT (parse_way (sub_node, error)); } - else if (g_str_equal (sub_node->name, "relation")) + else if (g_str_equal ((const char *) sub_node->name, "relation")) { object = MAPS_OSMOBJECT (parse_relation (sub_node, error)); } @@ -495,7 +495,7 @@ maps_osm_parse_user_details (const char *content, GError **error) return NULL; } - if (g_str_equal (sub_node->name, "user")) + if (g_str_equal ((const char *) sub_node->name, "user")) { g_autoptr (GHashTable) attributes; |