Skip to content

Commit f62edc0

Browse files
nobusodabrew
authored andcommitted
Made argument types strict for ruby 2.7 (#1096)
As function pointer arguments are declared strictly in Ruby 2.7, `do_send_query` and `do_query` cause warnings. ``` cd tmp/x86_64-darwin19/mysql2/2.7.0 /opt/local/bin/gmake compiling ../../../../ext/mysql2/client.c ../../../../ext/mysql2/client.c:787:14: warning: incompatible pointer types passing 'VALUE (void *)' (aka 'unsigned long (void *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-pointer-types] rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self, rb_eException, (VALUE)0); ^~~~~~~~~~~~~ /opt/local/include/ruby-2.7.0/ruby/ruby.h:1988:25: note: passing argument to parameter here VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...); ^ ../../../../ext/mysql2/client.c:795:16: warning: incompatible pointer types passing 'VALUE (void *)' (aka 'unsigned long (void *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-pointer-types] rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self, rb_eException, (VALUE)0); ^~~~~~~~ /opt/local/include/ruby-2.7.0/ruby/ruby.h:1988:25: note: passing argument to parameter here VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...); ^ 2 warnings generated. ```
1 parent 785969f commit f62edc0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/mysql2/client.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,10 @@ static void *nogvl_send_query(void *ptr) {
513513
return (void*)(rv == 0 ? Qtrue : Qfalse);
514514
}
515515

516-
static VALUE do_send_query(void *args) {
517-
struct nogvl_send_query_args *query_args = args;
516+
static VALUE do_send_query(VALUE args) {
517+
struct nogvl_send_query_args *query_args = (void *)args;
518518
mysql_client_wrapper *wrapper = query_args->wrapper;
519-
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, args, RUBY_UBF_IO, 0) == Qfalse) {
519+
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, query_args, RUBY_UBF_IO, 0) == Qfalse) {
520520
/* an error occurred, we're not active anymore */
521521
wrapper->active_thread = Qnil;
522522
rb_raise_mysql2_error(wrapper);
@@ -636,8 +636,8 @@ static VALUE disconnect_and_raise(VALUE self, VALUE error) {
636636
rb_exc_raise(error);
637637
}
638638

639-
static VALUE do_query(void *args) {
640-
struct async_query_args *async_args = args;
639+
static VALUE do_query(VALUE args) {
640+
struct async_query_args *async_args = (void *)args;
641641
struct timeval tv;
642642
struct timeval *tvp;
643643
long int sec;
@@ -797,7 +797,7 @@ static VALUE rb_mysql_query(VALUE self, VALUE sql, VALUE current) {
797797
return rb_ensure(rb_mysql_client_async_result, self, disconnect_and_mark_inactive, self);
798798
}
799799
#else
800-
do_send_query(&args);
800+
do_send_query((VALUE)&args);
801801

802802
/* this will just block until the result is ready */
803803
return rb_ensure(rb_mysql_client_async_result, self, disconnect_and_mark_inactive, self);

0 commit comments

Comments
 (0)