]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: stick-table: uninline stktable_alloc_data_type()
authorWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 12:10:42 +0000 (14:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 18:24:09 +0000 (20:24 +0200)
This function has no business being inlined in stick_table.h since it's
only used at boot time by the config parser. In addition it causes an
undesired dependency on tools.h because it uses parse_time_err(). Let's
move it to stick_table.c.

include/haproxy/stick_table.h
src/stick_table.c

index 5a3b400ba739180ed366563e013b09fde6620d8e..d8963b1d3e5851f7faf84711e023a3187050d53c 100644 (file)
@@ -87,45 +87,7 @@ static inline int stktable_type_size(int type)
        return 0;
 }
 
-/* reserve some space for data type <type>, and associate argument at <sa> if
- * not NULL. Returns PE_NONE (0) if OK or an error code among :
- *   - PE_ENUM_OOR if <type> does not exist
- *   - PE_EXIST if <type> is already registered
- *   - PE_ARG_NOT_USE if <sa> was provided but not expected
- *   - PE_ARG_MISSING if <sa> was expected but not provided
- */
-static inline int stktable_alloc_data_type(struct stktable *t, int type, const char *sa)
-{
-       if (type >= STKTABLE_DATA_TYPES)
-               return PE_ENUM_OOR;
-
-       if (t->data_ofs[type])
-               /* already allocated */
-               return PE_EXIST;
-
-       switch (stktable_data_types[type].arg_type) {
-       case ARG_T_NONE:
-               if (sa)
-                       return PE_ARG_NOT_USED;
-               break;
-       case ARG_T_INT:
-               if (!sa)
-                       return PE_ARG_MISSING;
-               t->data_arg[type].i = atoi(sa);
-               break;
-       case ARG_T_DELAY:
-               if (!sa)
-                       return PE_ARG_MISSING;
-               sa = parse_time_err(sa, &t->data_arg[type].u, TIME_UNIT_MS);
-               if (sa)
-                       return PE_ARG_INVC; /* invalid char */
-               break;
-       }
-
-       t->data_size      += stktable_type_size(stktable_data_types[type].std_type);
-       t->data_ofs[type]  = -t->data_size;
-       return PE_NONE;
-}
+int stktable_alloc_data_type(struct stktable *t, int type, const char *sa);
 
 /* 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).
index bb5c0ba6f7c13f13ed47503a9b031c9530989364..d16e1d01b1351caa7f2259ed0ba636227d1b22ca 100644 (file)
@@ -707,6 +707,46 @@ int stktable_parse_type(char **args, int *myidx, unsigned long *type, size_t *ke
        return 1;
 }
 
+/* reserve some space for data type <type>, and associate argument at <sa> if
+ * not NULL. Returns PE_NONE (0) if OK or an error code among :
+ *   - PE_ENUM_OOR if <type> does not exist
+ *   - PE_EXIST if <type> is already registered
+ *   - PE_ARG_NOT_USE if <sa> was provided but not expected
+ *   - PE_ARG_MISSING if <sa> was expected but not provided
+ */
+int stktable_alloc_data_type(struct stktable *t, int type, const char *sa)
+{
+       if (type >= STKTABLE_DATA_TYPES)
+               return PE_ENUM_OOR;
+
+       if (t->data_ofs[type])
+               /* already allocated */
+               return PE_EXIST;
+
+       switch (stktable_data_types[type].arg_type) {
+       case ARG_T_NONE:
+               if (sa)
+                       return PE_ARG_NOT_USED;
+               break;
+       case ARG_T_INT:
+               if (!sa)
+                       return PE_ARG_MISSING;
+               t->data_arg[type].i = atoi(sa);
+               break;
+       case ARG_T_DELAY:
+               if (!sa)
+                       return PE_ARG_MISSING;
+               sa = parse_time_err(sa, &t->data_arg[type].u, TIME_UNIT_MS);
+               if (sa)
+                       return PE_ARG_INVC; /* invalid char */
+               break;
+       }
+
+       t->data_size      += stktable_type_size(stktable_data_types[type].std_type);
+       t->data_ofs[type]  = -t->data_size;
+       return PE_NONE;
+}
+
 /*
  * Parse a line with <linenum> as number in <file> configuration file to configure
  * the stick-table with <t> as address and  <id> as ID.