sparse: Use offsetof macro to silence null ptr subtraction warning
PATCH 1/1 sparse: Use offsetof macro to silence null ptr subtraction warning
Subtracting (char *)0 is undefined behavior. Newer compilers warn about this unless it is done in system headers.
Signed-off-by Richard Palethorpe <[email protected]>
--- token.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
token.h +1 -1
@@ -201,7 +201,7 @@ struct token {static inline struct token *containing_token (struct token **p) { -void *addr = (char *)p - ((char *)&((struct token *)0 )->next - (char *)0 ); +void *addr = (char *)p - offsetof(struct token , next);return addr; }
Signature · 1 line
2.35.1
Quoted 2 lines · Richard Palethorpe
Subtracting (char *)0 is undefined behavior. Newer compilers warn about this unless it is done in system headers.
Thanks you, pushed now.
-- Luc