[LTP] [PATCH] sparse: Use offsetof macro to silence null ptr subtraction warning
Richard Palethorpe
rpalethorpe@suse.com
Mon Mar 21 12:21:19 CET 2022
Subtracting (char *)0 is undefined behavior. Newer compilers warn
about this unless it is done in system headers.
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
token.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/token.h b/token.h
index bccac0e4..9000e0cb 100644
--- a/token.h
+++ b/token.h
@@ -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;
}
--
2.35.1
More information about the ltp
mailing list