From b8c1490846280c796ac9d7acbe0791a133f1be80 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 27 Nov 2024 11:18:04 +0900 Subject: [PATCH] Prevent a warning of "a candidate for gnu_printf format attribute" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 13 prints the following warning. https://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20241127T001003Z.log.html.gz ``` compiling generator.c generator.c: In function ‘raise_generator_error’: generator.c:91:5: warning: function ‘raise_generator_error’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] 91 | VALUE str = rb_vsprintf(fmt, args); | ^~~~~ ``` This change prevents the warning by specifying the format attribute. --- ext/json/ext/generator/generator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index e4761fcb..67d2ea32 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -84,6 +84,9 @@ static void raise_generator_error_str(VALUE invalid_object, VALUE str) #ifdef RBIMPL_ATTR_NORETURN RBIMPL_ATTR_NORETURN() #endif +#ifdef RBIMPL_ATTR_FORMAT +RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3) +#endif static void raise_generator_error(VALUE invalid_object, const char *fmt, ...) { va_list args;