Skip to content

Commit d5c3f66

Browse files
committed
Crank up the compiler warnings
`-Weverything` doesn't usually get used because `ruby.h` doesn't compile with it as of 2.2.2.
1 parent 46a8187 commit d5c3f66

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

ext/mysql2/extconf.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,21 @@ def asplode lib
9898
asplode h unless have_header h
9999
end
100100

101-
# These gcc style flags are also supported by clang and xcode compilers,
102-
# so we'll use a does-it-work test instead of an is-it-gcc test.
103-
gcc_flags = ' -Wall -funroll-loops'
104-
if try_link('int main() {return 0;}', gcc_flags)
105-
$CFLAGS << gcc_flags
101+
# This is our wishlist. We use whichever flags work on the host.
102+
# -Wall and -Wextra are included by default.
103+
%w(
104+
-Werror
105+
-Weverything
106+
-fsanitize=address
107+
-fsanitize=integer
108+
-fsanitize=thread
109+
-fsanitize=memory
110+
-fsanitize=undefined
111+
-fsanitize=cfi
112+
).each do |flag|
113+
if try_link('int main() {return 0;}', flag)
114+
$CFLAGS << ' ' << flag
115+
end
106116
end
107117

108118
if RUBY_PLATFORM =~ /mswin|mingw/

ext/mysql2/result.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef struct {
5959
int streaming;
6060
ID db_timezone;
6161
ID app_timezone;
62-
int block_given;
62+
VALUE block_given;
6363
} result_each_args;
6464

6565
VALUE cBigDecimal, cDateTime, cDate;
@@ -346,8 +346,7 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
346346
}
347347

348348
{
349-
int r = (int)rb_thread_call_without_gvl(nogvl_stmt_fetch, wrapper->stmt, RUBY_UBF_IO, 0);
350-
switch(r) {
349+
switch((uintptr_t)rb_thread_call_without_gvl(nogvl_stmt_fetch, wrapper->stmt, RUBY_UBF_IO, 0)) {
351350
case 0:
352351
/* success */
353352
break;

0 commit comments

Comments
 (0)