summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2024-11-27 11:18:04 +0900
committerNobuyoshi Nakada <[email protected]>2024-11-27 23:35:20 +0900
commit209f8ba7c4ce0130fbdd3872b629a66f9c889910 (patch)
tree280192cd90757217e37fffe0e1b474fa50b80674
parent26d020cb6ea98adb38b370cf49b8101292d6f193 (diff)
[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
-rw-r--r--ext/json/generator/generator.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index e4761fcb8b..67d2ea32c4 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/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;