Hello, small cleanup patch attached.
Ilya
From 77babd04c417709bb41c951701d62dec0574eb35 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin <chipits...@gmail.com> Date: Sat, 15 Apr 2023 23:39:43 +0200 Subject: [PATCH] CLEANUP: use "offsetof" where appropriate let's use the C library macro "offsetof" --- src/cache.c | 4 ++-- src/ssl_sock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cache.c b/src/cache.c index 39e947820..4deb34ea8 100644 --- a/src/cache.c +++ b/src/cache.c @@ -425,12 +425,12 @@ static void delete_entry(struct cache_entry *del_entry) static inline struct shared_context *shctx_ptr(struct cache *cache) { - return (struct shared_context *)((unsigned char *)cache - ((struct shared_context *)NULL)->data); + return (struct shared_context *)((unsigned char *)cache - offsetof(struct shared_context, data)); } static inline struct shared_block *block_ptr(struct cache_entry *entry) { - return (struct shared_block *)((unsigned char *)entry - ((struct shared_block *)NULL)->data); + return (struct shared_block *)((unsigned char *)entry - offsetof(struct shared_block, data)); } diff --git a/src/ssl_sock.c b/src/ssl_sock.c index abbcfa6af..740fc0aeb 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -4205,7 +4205,7 @@ static inline void sh_ssl_sess_free_blocks(struct shared_block *first, struct sh /* return first block from sh_ssl_sess */ static inline struct shared_block *sh_ssl_sess_first_block(struct sh_ssl_sess_hdr *sh_ssl_sess) { - return (struct shared_block *)((unsigned char *)sh_ssl_sess - ((struct shared_block *)NULL)->data); + return (struct shared_block *)((unsigned char *)sh_ssl_sess - offsetof(struct shared_block, data)); } -- 2.40.0