From f486f976c7b981f70db962165970baed48504c36 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 25 Dec 2024 12:33:06 +0100 Subject: [PATCH] BUILD: limits: make normalize_rlim() take an rlim_t to fix build on m68k 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 | 4 ++-- src/debug.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/haproxy/limits.h b/include/haproxy/limits.h index 0185baf92..c512e4c7b 100644 --- a/include/haproxy/limits.h +++ b/include/haproxy/limits.h @@ -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 diff --git a/src/debug.c b/src/debug.c index cb33cf0b2..2987d36ef 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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); }