Philippe Mathieu-Daudé <[email protected]> writes:

> From: Akihiko Odaki <[email protected]>
>
> https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Warning-Options.html
>> Level 2 warns also about calls that might overflow the destination
>> buffer given an argument of sufficient length or magnitude. At level
>> 2, unknown numeric arguments are assumed to have the minimum
>> representable value for signed types with a precision greater than 1,
>> and the maximum representable value otherwise. Unknown string
>> arguments whose length cannot be assumed to be bounded either by the
>> directive’s precision, or by a finite set of string literals they may
>> evaluate to, or the character array they may point to, are assumed to
>> be 1 character long.
>
> Signed-off-by: Akihiko Odaki <[email protected]>
> Reviewed-by: Peter Maydell <[email protected]>
> Message-ID: <[email protected]>
> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
> ---
>  meson.build | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/meson.build b/meson.build
> index 102f0cbb13e..f45885f05a1 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -694,6 +694,7 @@ warn_flags = [
>    '-Wempty-body',
>    '-Wendif-labels',
>    '-Wexpansion-to-defined',
> +  '-Wformat-overflow=2',
>    '-Wformat-security',
>    '-Wformat-y2k',
>    '-Wignored-qualifiers',

This gives me:

../tests/qtest/ast2700-sgpio-test.c: In function ‘test_output_pins’:            
                                                                                
              
../tests/qtest/ast2700-sgpio-test.c:27:33: error: ‘sprintf’ may write a
terminating nul past the end of the destination
[-Werror=format-overflow=]

../tests/qtest/ast2700-sgpio-test.c: In function ‘test_irq_level_high’:         
                                          
../tests/qtest/ast2700-sgpio-test.c:85:33: error: ‘sprintf’ may write a
terminating nul past the end of the destination
[-Werror=format-overflow=]

../tests/qtest/arm-cpu-features.c: In function 
‘test_query_cpu_model_expansion_kvm’:                                           
                                               
../tests/qtest/arm-cpu-features.c:578:35: error: ‘%u’ directive writing
between 1 and 10 bytes into a region of size 5
[-Werror=format-overflow=]

../configure
--target-list=x86_64-softmmu,i386-softmmu,aarch64-softmmu,arm-softmmu,ppc64-softmmu,s390x-softmmu,riscv64-softmmu,aarch64-linux-user,loongarch64-softmmu
--disable-plugins --enable-modules --enable-werror
--enable-trace-backends=log,dtrace --enable-debug --enable-docs
--enable-rust --enable-strict-rust-lints

gcc version 7.5.0 (SUSE Linux)

Reply via email to