Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Made argument types strict for ruby 2.7 (brianmario#1096)
Browse files Browse the repository at this point in the history
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.
```
  • Loading branch information
nobu authored and Sneha Somwanshi committed Jan 22, 2020
1 parent 641a19a commit 49301bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ static void *nogvl_send_query(void *ptr) {
return (void*)(rv == 0 ? Qtrue : Qfalse);
}

static VALUE do_send_query(void *args) {
struct nogvl_send_query_args *query_args = args;
static VALUE do_send_query(VALUE args) {
struct nogvl_send_query_args *query_args = (void *)args;
mysql_client_wrapper *wrapper = query_args->wrapper;
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, args, RUBY_UBF_IO, 0) == Qfalse) {
if ((VALUE)rb_thread_call_without_gvl(nogvl_send_query, query_args, RUBY_UBF_IO, 0) == Qfalse) {
/* an error occurred, we're not active anymore */
wrapper->active_thread = Qnil;
rb_raise_mysql2_error(wrapper);
Expand Down Expand Up @@ -631,8 +631,8 @@ static VALUE disconnect_and_raise(VALUE self, VALUE error) {
rb_exc_raise(error);
}

static VALUE do_query(void *args) {
struct async_query_args *async_args = args;
static VALUE do_query(VALUE args) {
struct async_query_args *async_args = (void *)args;
struct timeval tv;
struct timeval *tvp;
long int sec;
Expand Down Expand Up @@ -792,7 +792,7 @@ static VALUE rb_mysql_query(VALUE self, VALUE sql, VALUE current) {
return rb_ensure(rb_mysql_client_async_result, self, disconnect_and_mark_inactive, self);
}
#else
do_send_query(&args);
do_send_query((VALUE)&args);

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

0 comments on commit 49301bb

Please sign in to comment.