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.
This commit is contained in:
Willy Tarreau 2024-12-25 12:33:06 +01:00
parent 21df7677a9
commit f486f976c7
2 changed files with 10 additions and 10 deletions

View 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

View 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);
}