From 568f0432bbf1653c0d0198111c5df1fd2556e11b Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 6 Nov 2012 21:02:55 +0000 Subject: [PATCH] Allow building with -Werror=format-security --- ruby/caca-canvas.c | 34 +++++++++++++++++----------------- ruby/caca-display.c | 8 ++++---- ruby/caca-dither.c | 8 ++++---- ruby/caca-font.c | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ruby/caca-canvas.c b/ruby/caca-canvas.c index 674bcc0..ed9b457 100644 --- a/ruby/caca-canvas.c +++ b/ruby/caca-canvas.c @@ -22,7 +22,7 @@ VALUE cCanvas; static VALUE x (VALUE self) \ { \ if( caca_##x (_SELF) <0) \ - rb_raise(rb_eRuntimeError, strerror(errno)); \ + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); \ \ return self; \ } @@ -58,7 +58,7 @@ static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height) if(canvas == NULL) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } _SELF = canvas; @@ -104,7 +104,7 @@ static VALUE set_canvas_size(VALUE self, VALUE height, VALUE width) static VALUE gotoxy(VALUE self, VALUE x, VALUE y) { if( caca_gotoxy(_SELF, NUM2INT(x), NUM2INT(y)) <0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return self; } @@ -150,7 +150,7 @@ static VALUE get_attr(VALUE self, VALUE x, VALUE y) static VALUE set_attr(VALUE self, VALUE attr) { if(caca_set_attr(_SELF, NUM2ULONG(attr)) <0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -164,7 +164,7 @@ static VALUE set_attr2(VALUE self, VALUE attr) static VALUE put_attr(VALUE self, VALUE x, VALUE y, VALUE attr) { if(caca_put_attr(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(attr)) <0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -172,7 +172,7 @@ static VALUE put_attr(VALUE self, VALUE x, VALUE y, VALUE attr) static VALUE set_color_ansi(VALUE self, VALUE fg, VALUE bg) { if(caca_set_color_ansi(_SELF, NUM2INT(fg), NUM2INT(bg)) <0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -180,7 +180,7 @@ static VALUE set_color_ansi(VALUE self, VALUE fg, VALUE bg) static VALUE set_color_argb(VALUE self, VALUE fg, VALUE bg) { if(caca_set_color_argb(_SELF, NUM2UINT(fg), NUM2UINT(bg)) <0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return self; } @@ -234,7 +234,7 @@ static VALUE blit(int argc, VALUE* argv, VALUE self) { cmask = NULL; if(caca_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -243,7 +243,7 @@ static VALUE set_canvas_boundaries(VALUE self, VALUE x, VALUE y, VALUE w, VALUE { if(caca_set_canvas_boundaries(_SELF, NUM2INT(x), NUM2INT(y), NUM2UINT(w), NUM2UINT(h))<0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return self; } @@ -524,7 +524,7 @@ get_int(frame_count) static VALUE set_frame(VALUE self, VALUE id) { if(caca_set_frame(_SELF, NUM2INT(id))<0) - rb_raise(rb_eArgError, strerror(errno)); + rb_raise(rb_eArgError, "%s", strerror(errno)); return self; } @@ -543,7 +543,7 @@ static VALUE get_frame_name(VALUE self) static VALUE set_frame_name(VALUE self, VALUE name) { if(caca_set_frame_name(_SELF, StringValuePtr(name))<0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -557,7 +557,7 @@ static VALUE set_frame_name2(VALUE self, VALUE name) static VALUE create_frame(VALUE self, VALUE id) { if(caca_create_frame(_SELF, NUM2INT(id))<0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return self; } @@ -565,7 +565,7 @@ static VALUE create_frame(VALUE self, VALUE id) static VALUE free_frame(VALUE self, VALUE id) { if(caca_free_frame(_SELF, NUM2INT(id))<0) { - rb_raise(rb_eArgError, strerror(errno)); + rb_raise(rb_eArgError, "%s", strerror(errno)); } return self; } @@ -602,7 +602,7 @@ static VALUE import_from_memory(VALUE self, VALUE data, VALUE format) long int bytes; bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format)); if(bytes <= 0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -612,7 +612,7 @@ static VALUE import_area_from_memory(VALUE self, VALUE x, VALUE y, VALUE data, V long int bytes; bytes = caca_import_area_from_memory (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format)); if(bytes <= 0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -622,7 +622,7 @@ static VALUE import_from_file(VALUE self, VALUE filename, VALUE format) long int bytes; bytes = caca_import_canvas_from_file (_SELF, StringValuePtr(filename), StringValuePtr(format)); if(bytes <= 0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } @@ -632,7 +632,7 @@ static VALUE import_area_from_file(VALUE self, VALUE x, VALUE y, VALUE filename, long int bytes; bytes = caca_import_area_from_file (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(filename), StringValuePtr(format)); if(bytes <= 0) - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); return self; } diff --git a/ruby/caca-display.c b/ruby/caca-display.c index 4c885f0..8d894cb 100644 --- a/ruby/caca-display.c +++ b/ruby/caca-display.c @@ -84,7 +84,7 @@ static VALUE display_initialize(int argc, VALUE* argv, VALUE self) if(display == NULL) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } _SELF = display; @@ -131,7 +131,7 @@ static VALUE set_title(VALUE self, VALUE t) { if(caca_set_display_title(_SELF, StringValuePtr(t))<0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return t; } @@ -252,7 +252,7 @@ static VALUE set_driver(VALUE self, VALUE driver) { if(caca_set_display_driver(_SELF, StringValuePtr(driver))<0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return driver; } @@ -267,7 +267,7 @@ static VALUE set_cursor(VALUE self, VALUE flag) { if(caca_set_cursor(_SELF, flag)<0) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } return flag; } diff --git a/ruby/caca-dither.c b/ruby/caca-dither.c index a86c98f..44de539 100644 --- a/ruby/caca-dither.c +++ b/ruby/caca-dither.c @@ -35,7 +35,7 @@ static VALUE dither_initialize(VALUE self, VALUE bpp, VALUE w, VALUE h, VALUE pi dither = caca_create_dither(NUM2UINT(bpp), NUM2UINT(w), NUM2UINT(h), NUM2UINT(pitch), NUM2ULONG(rmask), NUM2ULONG(gmask), NUM2ULONG(bmask), NUM2ULONG(amask)); if(dither == NULL) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } _SELF = dither; return self; @@ -121,7 +121,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette) free(green); free(blue); free(alpha); - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } free(red); @@ -142,7 +142,7 @@ static VALUE set_dither_palette2(VALUE self, VALUE palette) static VALUE set_##x(VALUE self, VALUE x) \ { \ if(caca_set_dither_##x(_SELF, (float)NUM2DBL(x))<0) \ - rb_raise(rb_eRuntimeError, strerror(errno)); \ + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); \ \ return x; \ } \ @@ -163,7 +163,7 @@ static VALUE set_dither_##x(VALUE self, VALUE x) \ { \ if(caca_set_dither_##x(_SELF, StringValuePtr(x))<0) \ { \ - rb_raise(rb_eRuntimeError, strerror(errno)); \ + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); \ } \ return x; \ } \ diff --git a/ruby/caca-font.c b/ruby/caca-font.c index 391ef3f..f09bcde 100644 --- a/ruby/caca-font.c +++ b/ruby/caca-font.c @@ -35,7 +35,7 @@ static VALUE font_initialize(VALUE self, VALUE name) font = caca_load_font(StringValuePtr(name), 0); if(font == NULL) { - rb_raise(rb_eRuntimeError, strerror(errno)); + rb_raise(rb_eRuntimeError, "%s", strerror(errno)); } _SELF = font; return self;