From: Willy Tarreau Date: Thu, 20 Sep 2018 09:06:33 +0000 (+0200) Subject: MINOR: stktable: provide an unchecked version of stktable_data_ptr() X-Git-Tag: v1.9-dev3~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=babc15e8cfa4fc6f633d45e66fea24922964413d;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h index 59674f611d..40bb8ca6c2 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 */