[ruby/json] 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.

https://github.com/ruby/json/commit/b8c1490846
This commit is contained in:
Yusuke Endoh 2024-11-27 11:18:04 +09:00 committed by Nobuyoshi Nakada
parent 26d020cb6e
commit 209f8ba7c4

View File

@ -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;