]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: limits: make normalize_rlim() take an rlim_t to fix build on m68k
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:33:06 +0000 (12:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:33:06 +0000 (12:33 +0100)
As can be seen here, the build fails on m68k since commit 665dde648
("MINOR: debug: use LIM2A to show limits") in 3.1:

  https://github.com/haproxy/haproxy/actions/runs/12440234399/job/34735360177

The reason is the comparison between a ulong limit and RLIM_INFINITY.
Indeed, on m68k, rlim_t is an unsigned long long. Let's just change
the function's input type to take an rlim_t instead. This also allows
to get rid of the casts in the call place.

This can be backported to 3.1 though it's not important given the low
prevalence of this platform for such use cases.

include/haproxy/limits.h
src/debug.c

index 0185baf927e7a893c1f5a593d941b9a156159ad2..c512e4c7bfbf675a7111ca52a9d98540532be206 100644 (file)
@@ -19,12 +19,12 @@ extern unsigned int rlim_fd_max_at_boot;
  * returns the limit, useful to print limit values as strings in err messages
  * via LIM2A macros.
  */
-static inline ulong normalize_rlim(ulong rlim)
+static inline ulong normalize_rlim(rlim_t rlim)
 {
        if (rlim == RLIM_INFINITY)
                return 0;
 
-       return rlim;
+       return (ulong)rlim;
 }
 
 /* handlers to compute internal process limits, if they are not provided via
index cb33cf0b28b69c61e0de88488f7986d08370284e..2987d36ef0011b60338c5b47cf1283cb0754920f 100644 (file)
@@ -636,23 +636,23 @@ static int debug_parse_cli_show_dev(char **args, char *payload, struct appctx *a
 #endif
        chunk_appendf(&trash, "  boot limits:\n");
        chunk_appendf(&trash, "  \tfd limit (soft): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.boot_lim_fd.rlim_cur), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.boot_lim_fd.rlim_cur), "unlimited"));
        chunk_appendf(&trash, "  \tfd limit (hard): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.boot_lim_fd.rlim_max), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.boot_lim_fd.rlim_max), "unlimited"));
        chunk_appendf(&trash, "  \tram limit (soft): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.boot_lim_ram.rlim_cur), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.boot_lim_ram.rlim_cur), "unlimited"));
        chunk_appendf(&trash, "  \tram limit (hard): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.boot_lim_ram.rlim_max), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.boot_lim_ram.rlim_max), "unlimited"));
 
        chunk_appendf(&trash, "  runtime limits:\n");
        chunk_appendf(&trash, "  \tfd limit (soft): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_fd.rlim_cur), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.run_lim_fd.rlim_cur), "unlimited"));
        chunk_appendf(&trash, "  \tfd limit (hard): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_fd.rlim_max), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.run_lim_fd.rlim_max), "unlimited"));
        chunk_appendf(&trash, "  \tram limit (soft): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_ram.rlim_cur), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.run_lim_ram.rlim_cur), "unlimited"));
        chunk_appendf(&trash, "  \tram limit (hard): %s\n",
-                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_ram.rlim_max), "unlimited"));
+                     LIM2A(normalize_rlim(post_mortem.process.run_lim_ram.rlim_max), "unlimited"));
 
        return cli_msg(appctx, LOG_INFO, trash.area);
 }