From fbdc046e9561829265588582a0e5926eda1eaa88 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Mon, 21 Mar 2022 11:21:19 +0000 Subject: 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 Signed-off-by: Luc Van Oostenryck --- 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; } -- cgit 1.2.3-korg