[Skiboot] [PATCH] hdata/test: Build with -Wno-error=unterminated-string-initialization

Dan Horák dan at danny.cz
Thu Jan 30 03:15:41 AEDT 2025


On Wed, 29 Jan 2025 10:01:04 -0600
Reza Arbab <arbab at linux.ibm.com> wrote:

> Six bytes of the HDIF header are used as an eye catcher:
> 
>   struct HDIF_common_hdr {
>   	...
>   	char    id[6];          /* eye catcher string */
>   	...
>   }
> 
> We assign all six characters of this string without a terminating nul,
> so now that GCC 15 enables -Werror=unterminated-string-initialization by
> default, the build breaks:
> 
>   In file included from hdata/test/../spira.h:7,
>                    from hdata/test/../cpu-common.c:5,
>                    from hdata/test/hdata_to_dt.c:148:
>   hdata/test/../spira.c:35:32: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
>      35 |         .hdr = HDIF_SIMPLE_HDR("PROCIN", 1, struct proc_init_data),
>         |                                ^~~~~~~~
>   hdata/test/../hdif.h:45:68: note: in definition of macro 'HDIF_ID'
>      45 | #define HDIF_ID(_id)            .d1f0 = CPU_TO_BE16(0xd1f0), .id = _id
>         |                                                                    ^~~
>   hdata/test/../spira.c:35:16: note: in expansion of macro 'HDIF_SIMPLE_HDR'
>      35 |         .hdr = HDIF_SIMPLE_HDR("PROCIN", 1, struct proc_init_data),
>         |                ^~~~~~~~~~~~~~~
>   hdata/test/../spira.h:797:33: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
>     797 | #define CPU_CTL_HDIF_SIG        "CPUCTL"
>         |                                 ^~~~~~~~
>   hdata/test/../hdif.h:45:68: note: in definition of macro 'HDIF_ID'
>      45 | #define HDIF_ID(_id)            .d1f0 = CPU_TO_BE16(0xd1f0), .id = _id
>         |                                                                    ^~~
>   hdata/test/../spira.c:73:16: note: in expansion of macro 'HDIF_SIMPLE_HDR'
>      73 |         .hdr = HDIF_SIMPLE_HDR(CPU_CTL_HDIF_SIG, 2, struct cpu_ctl_init_data),
>         |                ^~~~~~~~~~~~~~~
>   hdata/test/../spira.c:73:32: note: in expansion of macro 'CPU_CTL_HDIF_SIG'
>      73 |         .hdr = HDIF_SIMPLE_HDR(CPU_CTL_HDIF_SIG, 2, struct cpu_ctl_init_data),
>         |                                ^~~~~~~~~~~~~~~~
>   hdata/test/../spira.h:30:33: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
>      30 | #define SPIRAH_HDIF_SIG         "SPIRAH"
>         |                                 ^~~~~~~~
>   hdata/test/../hdif.h:45:68: note: in definition of macro 'HDIF_ID'
>      45 | #define HDIF_ID(_id)            .d1f0 = CPU_TO_BE16(0xd1f0), .id = _id
>         |                                                                    ^~~
>   hdata/test/../spira.c:126:16: note: in expansion of macro 'HDIF_SIMPLE_HDR'
>     126 |         .hdr = HDIF_SIMPLE_HDR(SPIRAH_HDIF_SIG, SPIRAH_VERSION, struct spirah),
>         |                ^~~~~~~~~~~~~~~
>   hdata/test/../spira.c:126:32: note: in expansion of macro 'SPIRAH_HDIF_SIG'
>     126 |         .hdr = HDIF_SIMPLE_HDR(SPIRAH_HDIF_SIG, SPIRAH_VERSION, struct spirah),
>         |                                ^~~~~~~~~~~~~~~
> 
> To ignore the spurious error, build the single testcase that trips this
> with -Wno-error=unterminated-string-initialization.
> 
> Signed-off-by: Reza Arbab <arbab at linux.ibm.com>

LGTM

Reviewed-by: Dan Horák <dan at danny.cz>


		Dan


> ---
>  hdata/test/Makefile.check | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hdata/test/Makefile.check b/hdata/test/Makefile.check
> index 81d55614a5b7..5950bf95f399 100644
> --- a/hdata/test/Makefile.check
> +++ b/hdata/test/Makefile.check
> @@ -13,6 +13,8 @@ coverage: hdata-coverage
>  LCOV_EXCLUDE += $(HDATA_TEST:%=%.c) hdata/test/stubs.c
>  LCOV_EXCLUDE += /usr/include/valgrind/memcheck.h
>  
> +hdata/test/hdata_to_dt hdata/test/hdata_to_dt-gcov: HOSTCFLAGS += $(call try-cflag,$(HOSTCC),-Wno-error=unterminated-string-initialization)
> +
>  hdata/test/hdata_to_dt-check: hdata/test/hdata_to_dt-check-q
>  hdata/test/hdata_to_dt-check: hdata/test/hdata_to_dt-check-dt
>  
> -- 
> 2.43.5
> 
> _______________________________________________
> Skiboot mailing list
> Skiboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot


More information about the Skiboot mailing list