]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stktable: provide an unchecked version of stktable_data_ptr()
authorWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 09:06:33 +0000 (11:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 09:42:15 +0000 (11:42 +0200)
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

index 59674f611dddca49fa7fdcaef75a8956735c6289..40bb8ca6c2b566bcba8ea28b0e2611d962f98e1b 100644 (file)
@@ -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 <type> in sticky session <ts> of table <t>, 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 <type> in sticky session <ts> of table <t>, or
  * NULL if either <ts> 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 */