]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: mux-h2: get rid of the redundant h2_parse_int() function
authorWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 12:43:39 +0000 (13:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 14:06:15 +0000 (15:06 +0100)
This one was brought by commiy 8475b372c ("BUG/MINOR: mux-h2: reject
non-numeric values in the tune.h2 keywords") but is no longer needed
with the recent intops additions, let's get rid of it.

src/mux_h2.c

index 56c03a1f99e23c7099ee213888563248477002fc..920ee1c13a1cbdc188aaf3222a416f4d20f9f579 100644 (file)
@@ -9081,23 +9081,6 @@ static int h2_takeover(struct connection *conn, int orig_tid, int release)
 /* functions below are dedicated to the config parsers */
 /*******************************************************/
 
-/* Parses <arg> as a decimal integer into <*val>. Returns 0 on success, or -1
- * if <arg> is empty, contains anything but an optional sign and digits, or
- * does not fit in an int.
- */
-static int h2_parse_int(const char *arg, int *val)
-{
-       char *end;
-       long v;
-
-       errno = 0;
-       v = strtol(arg, &end, 10);
-       if (!*arg || *end || errno || v < INT_MIN || v > INT_MAX)
-               return -1;
-       *val = v;
-       return 0;
-}
-
 /* config parser for global "tune.h2.{fe,be}.glitches-threshold" */
 static int h2_parse_glitches_threshold(char **args, int section_type, struct proxy *curpx,
                                       const struct proxy *defpx, const char *file, int line,
@@ -9111,7 +9094,7 @@ static int h2_parse_glitches_threshold(char **args, int section_type, struct pro
        /* backend/frontend */
        vptr = (args[0][8] == 'b') ? &h2_be_glitches_threshold : &h2_fe_glitches_threshold;
 
-       if (h2_parse_int(args[1], vptr) || *vptr < 0) {
+       if (str2irc(args[1], vptr) != 0 || *vptr < 0) {
                memprintf(err, "'%s' expects a positive numeric value.", args[0]);
                return -1;
        }
@@ -9126,7 +9109,7 @@ static int h2_parse_header_table_size(char **args, int section_type, struct prox
        if (too_many_args(1, args, err, NULL))
                return -1;
 
-       if (h2_parse_int(args[1], &h2_settings_header_table_size) ||
+       if (str2irc(args[1], &h2_settings_header_table_size) != 0 ||
            h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
                memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]);
                return -1;
@@ -9149,7 +9132,7 @@ static int h2_parse_initial_window_size(char **args, int section_type, struct pr
               (args[0][8] == 'f') ? &h2_fe_settings_initial_window_size :
               &h2_settings_initial_window_size;
 
-       if (h2_parse_int(args[1], vptr) || *vptr < 0) {
+       if (str2irc(args[1], vptr) != 0 || *vptr < 0) {
                memprintf(err, "'%s' expects a positive numeric value.", args[0]);
                return -1;
        }
@@ -9198,7 +9181,7 @@ static int h2_parse_max_concurrent_streams(char **args, int section_type, struct
        if (args[0][8] != 'f' && too_many_args(1, args, err, NULL))
                return -1;
 
-       if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+       if (str2uirc(args[1], vptr) != 0) {
                memprintf(err, "'%s' expects a positive numeric value.", args[0]);
                return -1;
        }
@@ -9213,13 +9196,13 @@ static int h2_parse_max_concurrent_streams(char **args, int section_type, struct
                                h2_fe_max_rq_load = ~0;
                        else if (strcmp(args[arg + 1], "auto") == 0)
                                h2_fe_max_rq_load = 0;
-                       else if (h2_parse_int(args[arg + 1], (int *)&h2_fe_max_rq_load) || (int)h2_fe_max_rq_load <= 0) {
+                       else if (str2uirc(args[arg + 1], &h2_fe_max_rq_load) != 0 || h2_fe_max_rq_load == 0) {
                                memprintf(err, "'%s' expects a strictly positive run-queue length, or 'auto' or 'ignore'.", args[0]);
                                return -1;
                        }
                }
                else if (strcmp(args[arg], "min") == 0) {
-                       if (h2_parse_int(args[arg + 1], (int *)&h2_fe_min_concurrent_streams) || (int)h2_fe_min_concurrent_streams <= 0) {
+                       if (str2uirc(args[arg + 1], &h2_fe_min_concurrent_streams) != 0|| h2_fe_min_concurrent_streams == 0) {
                                memprintf(err, "'%s' expects a strictly positive minimum number of streams'.", args[0]);
                                return -1;
                        }
@@ -9252,7 +9235,7 @@ static int h2_parse_max_total_streams(char **args, int section_type, struct prox
        /* frontend only for now */
        vptr = &h2_fe_max_total_streams;
 
-       if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+       if (str2uirc(args[1], vptr) != 0) {
                memprintf(err, "'%s' expects a positive numeric value.", args[0]);
                return -1;
        }
@@ -9279,7 +9262,7 @@ static int h2_parse_max_frames_at_once(char **args, int section_type, struct pro
        if (too_many_args(1, args, err, NULL))
                return -1;
 
-       if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+       if (str2uirc(args[1], vptr) != 0) {
                memprintf(err, "'%s' expects a positive numeric value.", args[0]);
                return -1;
        }
@@ -9294,7 +9277,7 @@ static int h2_parse_max_frame_size(char **args, int section_type, struct proxy *
        if (too_many_args(1, args, err, NULL))
                return -1;
 
-       if (h2_parse_int(args[1], &h2_settings_max_frame_size) ||
+       if (str2irc(args[1], &h2_settings_max_frame_size) != 0 ||
            h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
                memprintf(err, "'%s' expects a numeric value between 16384 and 16777215.", args[0]);
                return -1;