Skip to content

Commit b8c1490

Browse files
committed
Prevent a warning of "a candidate for gnu_printf format attribute"
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.
1 parent dbd5042 commit b8c1490

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/json/ext/generator/generator.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ static void raise_generator_error_str(VALUE invalid_object, VALUE str)
8484
#ifdef RBIMPL_ATTR_NORETURN
8585
RBIMPL_ATTR_NORETURN()
8686
#endif
87+
#ifdef RBIMPL_ATTR_FORMAT
88+
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
89+
#endif
8790
static void raise_generator_error(VALUE invalid_object, const char *fmt, ...)
8891
{
8992
va_list args;

0 commit comments

Comments
 (0)