]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: mworker: silence two printf format warnings around getpid()
authorWilly Tarreau <w@1wt.eu>
Sat, 22 Jun 2019 05:41:38 +0000 (07:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 22 Jun 2019 05:57:56 +0000 (07:57 +0200)
getpid() is documented as returning a pit pid_t result, not
necessarily an int. This causes a build warning on Solaris 10
because of '%d' or '%u' are used in the format passed to snprintf().
Let's just cast the result as an int (respectively unsigned int).

This can be backported to 2.0 and possibly older versions though
it really has no impact.

src/haproxy.c
src/mworker.c

index c9b61c6a22f540c77b38ac7a1263e7c85fea2c98..c3a448264ff9219555662e7d05a73852ed522493 100644 (file)
@@ -3006,7 +3006,7 @@ int main(int argc, char **argv)
                /* if in master-worker mode, write the PID of the father */
                if (global.mode & MODE_MWORKER) {
                        char pidstr[100];
-                       snprintf(pidstr, sizeof(pidstr), "%d\n", getpid());
+                       snprintf(pidstr, sizeof(pidstr), "%d\n", (int)getpid());
                        if (pidfd >= 0)
                                shut_your_big_mouth_gcc(write(pidfd, pidstr, strlen(pidstr)));
                }
index 6a4f1f57555f1f435cf414b8e030011a01e5e738..511d9617dc41fe89053a6e4500e8aaeec015e402 100644 (file)
@@ -449,7 +449,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
 
        chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s %-15s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>", "<version>");
        memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
-       chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", getpid(), "master", 0, proc_self->reloads, uptime, haproxy_version);
+       chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", (unsigned int)getpid(), "master", 0, proc_self->reloads, uptime, haproxy_version);
        free(uptime);
        uptime = NULL;