xen/mcelog: Add __nonstring annotations for unterminated strings
PATCH 1/1 xen/mcelog: Add __nonstring annotations for unterminated strings
When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.
Cc Juergen Gross <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Oleksandr Tyshchenko <[email protected]>
Signed-off-by Kees Cook <[email protected]>
--- include/xen/interface/xen-mca.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/xen/interface/xen-mca.h +1 -1
@@ -372,7 +372,7 @@ struct xen_mce {#define XEN_MCE_LOG_LEN 32struct xen_mce_log { -char signature[12 ];/* "MACHINECHECK" */ + char signature[12] __nonstring; /* "MACHINECHECK" */unsigned len;/* = XEN_MCE_LOG_LEN */ unsigned next; unsigned flags;
Signature · 1 line
2.34.1
Quoted 6 lines · Kees Cook
When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with
__nonstringto and correctly identify the char array as "not a C string" and thereby eliminate the warning.
Quoted 6 lines
Cc Juergen Gross <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Oleksandr Tyshchenko <[email protected]>Signed-off-by Kees Cook <[email protected]>
Acked-by Juergen Gross <[email protected]>
Juergen