From 7c46f7383cc7fd8a2ddab362ca608a638b42a6a7 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Tue, 25 Aug 2020 21:56:15 +0200 Subject: [PATCH 1/2] Fix gcc warning about mismatching function pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../../../../ext/nokogiri/xml_document.c: In function ‘dealloc’: ../../../../ext/nokogiri/xml_document.c:58:25: warning: passing argument 2 of ‘rb_st_foreach’ from incompatible pointer type [-Wincompatible-pointer-types] 58 | st_foreach(node_hash, dealloc_node_i, (st_data_t)doc); | ^~~~~~~~~~~~~~ | | | int (*)(xmlNode *, xmlNode *, xmlDoc *) {aka int (*)(struct _xmlNode *, struct _xmlNode *, struct _xmlDoc *)} --- ext/nokogiri/xml_document.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/nokogiri/xml_document.c b/ext/nokogiri/xml_document.c index df1aab7e603..3a8ba06e3e6 100644 --- a/ext/nokogiri/xml_document.c +++ b/ext/nokogiri/xml_document.c @@ -1,6 +1,6 @@ #include -static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc) +static int dealloc_node_i2(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc) { switch(node->type) { case XML_ATTRIBUTE_NODE: @@ -20,6 +20,11 @@ static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc) return ST_CONTINUE; } +static int dealloc_node_i(st_data_t key, st_data_t node, st_data_t doc) +{ + return dealloc_node_i2((xmlNodePtr)key, (xmlNodePtr)node, (xmlDocPtr)doc); +} + static void remove_private(xmlNodePtr node) { xmlNodePtr child; From 6c0af79e40c4de7680bdb42abfc0f264dffb9b95 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Tue, 25 Aug 2020 21:58:13 +0200 Subject: [PATCH 2/2] Fix gcc warning about mismatching function pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../../../../ext/nokogiri/xml_io.c: In function ‘io_read_callback’: ../../../../ext/nokogiri/xml_io.c:20:22: warning: passing argument 1 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types] 20 | string = rb_rescue(read_check, (VALUE)args, read_failed, 0); | ^~~~~~~~~~ | | | VALUE (*)(VALUE *) {aka long unsigned int (*)(long unsigned int *)} and ../../../../ext/nokogiri/xml_io.c:20:47: warning: passing argument 3 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types] 20 | string = rb_rescue(read_check, (VALUE)args, read_failed, 0); | ^~~~~~~~~~~ | | | VALUE (*)(void) {aka long unsigned int (*)(void)} --- ext/nokogiri/xml_io.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/nokogiri/xml_io.c b/ext/nokogiri/xml_io.c index 46655e47312..e6cae1d2e1b 100644 --- a/ext/nokogiri/xml_io.c +++ b/ext/nokogiri/xml_io.c @@ -2,12 +2,13 @@ static ID id_read, id_write; -VALUE read_check(VALUE *args) { +VALUE read_check(VALUE val) { + VALUE *args = (VALUE *)val; return rb_funcall(args[0], id_read, 1, args[1]); } -VALUE read_failed(void) { - return Qundef; +VALUE read_failed(VALUE arg, VALUE exc) { + return Qundef; } int io_read_callback(void * ctx, char * buffer, int len) { @@ -30,12 +31,13 @@ int io_read_callback(void * ctx, char * buffer, int len) { return (int)safe_len; } -VALUE write_check(VALUE *args) { +VALUE write_check(VALUE val) { + VALUE *args = (VALUE *)val; return rb_funcall(args[0], id_write, 1, args[1]); } -VALUE write_failed(void) { - return Qundef; +VALUE write_failed(VALUE arg, VALUE exc) { + return Qundef; } int io_write_callback(void * ctx, char * buffer, int len) {