CLEANUP: use "offsetof" where appropriate

let's use the C library macro "offsetof"
This commit is contained in:
Ilya Shipitsin 2023-04-15 23:39:43 +02:00 committed by Willy Tarreau
parent b5efe7901d
commit 2ca01589a0
2 changed files with 3 additions and 3 deletions

View File

@ -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));
}

View File

@ -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));
}