-
Notifications
You must be signed in to change notification settings - Fork 419
Fixes format-security error when compiling ruby_193_compatible.h #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes format-security error when compiling ruby_193_compatible.h #536
Conversation
19c0b4b
to
316e043
Compare
@@ -17,12 +17,12 @@ static inline void rb_error_arity(int argc, int min, int max) | |||
else { | |||
err_mess = rb_sprintf("wrong number of arguments (%d for %d..%d)", argc, min, max); | |||
} | |||
rb_raise(rb_eTypeError, err_mess); | |||
return rb_ext_new3(rb_eTypeError, err_mess); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you find the documentation on rb_ext_new3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that's supposed to be rb_exc_new3
- fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised the Travis build succeeded. It looks like the extension is being compiled with very lenient settings, to the extent that calling non-existent functions isn't even considered an error!
When compiling the extension for Ruby 1.9 on a system that treats format-security warnings as errors (i.e. the Makefile generated for the extension contains "-Werror=format-security"), compilation would fail with the following error: ``` compiling atomic_boolean.c In file included from atomic_boolean.c:5:0: ruby_193_compatible.h: In function 'rb_error_arity': ruby_193_compatible.h:20:3: warning: passing argument 2 of 'rb_raise' makes pointer from integer without a cast [enabled by default] rb_raise(rb_eTypeError, err_mess); ^ In file included from /usr/include/ruby-1.9.1/ruby.h:32:0, from atomic_boolean.c:1: /usr/include/ruby-1.9.1/ruby/ruby.h:1172:27: note: expected 'const char *' but argument is of type 'VALUE' PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3); ^ /usr/include/ruby-1.9.1/ruby/ruby.h:42:3: note: in definition of macro 'PRINTF_ARGS' decl __attribute__((format(printf, string_index, first_to_check))) ^ /usr/include/ruby-1.9.1/ruby/ruby.h:1172:13: note: in expansion of macro 'NORETURN' PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3); ^ In file included from atomic_boolean.c:5:0: ruby_193_compatible.h:20:3: error: format not a string literal and no format arguments [-Werror=format-security] rb_raise(rb_eTypeError, err_mess); ^ cc1: some warnings being treated as errors make: *** [atomic_boolean.o] Error 1 ``` This updates these functions to work more like the original copies (found in the Ruby 2.0+ source code), which avoids this compilation error.
316e043
to
b3fa771
Compare
@RJPercival Thanks very much for the fix. I'll defer to @jdantonio for review though. |
Thank you! |
Fixes #516. When compiling the extension for Ruby 1.9 on a system that treats format-security warnings as errors (i.e. the Makefile generated for the extension contains "-Werror=format-security"), compilation would fail with the following error:
This updates the functions in ruby_193_compatible.h to work more like the original copies (found in the Ruby 2.0+ source code), which avoids this compilation error.