]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: init: print rlim_cur as regular integer
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 May 2023 12:04:18 +0000 (14:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 26 May 2023 12:29:52 +0000 (14:29 +0200)
haproxy does not compile anymore on macOS+clang since 425d7ad ("MINOR:
init: pre-allocate kernel data structures on init"). This is due to
rlim_cur being printed uncasted using %lu format specifier, with rlim_cur
being stored as a rlim_t which is a typedef so its size may vary depending
on the system's architecture.

This is not the first time we need to dump rlim_cur in case of errors,
there are already multiple occurences in the init code. Everywhere this
happens, rlim is casted as a regular int and printed using the '%d'
format specifier, so we do the same here as well to fix the build issue.

No backport needed unless 425d7ad gets backported.

src/haproxy.c

index 04056470199fdcfe8cec4d3cbcccb07a092200d3..93b0780108639eb46f990e1d46cea41d646b7820 100644 (file)
@@ -3524,8 +3524,8 @@ int main(int argc, char **argv)
 
        if (global.prealloc_fd && fcntl((int)limit.rlim_cur - 1, F_GETFD) == -1) {
                if (dup2(0, (int)limit.rlim_cur - 1) == -1)
-                       ha_warning("[%s.main()] Unable to preallocate file descriptor %lu : %s",
-                                  argv[0], limit.rlim_cur-1, strerror(errno));
+                       ha_warning("[%s.main()] Unable to preallocate file descriptor %d : %s",
+                                  argv[0], (int)limit.rlim_cur - 1, strerror(errno));
                else
                        close((int)limit.rlim_cur - 1);
        }