From babc15e8cfa4fc6f633d45e66fea24922964413d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 20 Sep 2018 11:06:33 +0200 Subject: [PATCH] MINOR: stktable: provide an unchecked version of stktable_data_ptr() stktable_data_ptr() currently performs null pointer checks but most callers don't check the result since they know by construction that it cannot be null. This causes valid warnings when building with -Wextra which are worth addressing since it will result in better code. Let's provide an unguarded version of this function for use where the check is known to be useless and untested. --- include/proto/stick_table.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h index 59674f611..40bb8ca6c 100644 --- a/include/proto/stick_table.h +++ b/include/proto/stick_table.h @@ -113,6 +113,14 @@ static inline int stktable_alloc_data_type(struct stktable *t, int type, const c return PE_NONE; } +/* return pointer for data type in sticky session of table , all + * of which must exist (otherwise use stktable_data_ptr() if unsure). + */ +static inline void *__stktable_data_ptr(struct stktable *t, struct stksess *ts, int type) +{ + return (void *)ts + t->data_ofs[type]; +} + /* return pointer for data type in sticky session of table , or * NULL if either is NULL or the type is not stored. */ @@ -127,7 +135,7 @@ static inline void *stktable_data_ptr(struct stktable *t, struct stksess *ts, in if (!ts) return NULL; - return (void *)ts + t->data_ofs[type]; + return __stktable_data_ptr(t, ts, type); } /* kill an entry if it's expired and its ref_cnt is zero */