]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
cast pid_t to int when used in format strings
authorRoy Marples <roy@marples.name>
Tue, 15 Apr 2025 13:28:10 +0000 (14:28 +0100)
committerRoy Marples <roy@marples.name>
Tue, 15 Apr 2025 13:28:10 +0000 (14:28 +0100)
Silences warnings on Solaris

compat/pidfile.c
src/dhcp.c
src/dhcpcd.c
src/ipv4ll.c
src/ipv6.c
src/logerr.c
src/route.c
src/script.c

index 8d2e5a838c0ea7576cb4f745d8c1204e24643f4c..b89738bd23a970e44ffa3a1c288fd5f53725326d 100644 (file)
@@ -257,7 +257,7 @@ return_pid:
         * Then write the process ID. */
        if (ftruncate(pidfile_fd, 0) == -1 ||
            lseek(pidfile_fd, 0, SEEK_SET) == -1 ||
-           dprintf(pidfile_fd, "%d\n", pidfile_pid) == -1)
+           dprintf(pidfile_fd, "%d\n", (int)pidfile_pid) == -1)
        {
                int error = errno;
 
index 436399cb017d33e1d87c47db7644d203adca2599..b294bd67f0bd13b371caa01c9ceeebab2dedf973 100644 (file)
@@ -4335,7 +4335,7 @@ dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
        if (cmd == RTM_DELADDR) {
                if (state->addr == ia) {
                        loginfox("%s: pid %d deleted IP address %s",
-                           ifp->name, pid, ia->saddr);
+                           ifp->name, (int)pid, ia->saddr);
                        dhcp_close(ifp);
                        state->addr = NULL;
                        /* Don't clear the added state as we need
index 7cea7bd5f061ac4110439559c1a6b8471de5aed6..3e138cbc490b01c86d6e33dd2cb1b5e535d4a2ab 100644 (file)
@@ -1896,7 +1896,7 @@ dhcpcd_pidfile_timeout(void *arg)
        if(pid == -1)
                eloop_exit(ctx->eloop, EXIT_SUCCESS);
        else if (++ctx->duid_len >= 100) { /* overload duid_len */
-               logerrx("pid %d failed to exit", pid);
+               logerrx("pid %d failed to exit", (int)pid);
                eloop_exit(ctx->eloop, EXIT_FAILURE);
        } else
                eloop_timeout_add_msec(ctx->eloop, 100,
@@ -2247,7 +2247,7 @@ printpidfile:
        if (sig != 0) {
                pid = pidfile_read(ctx.pidfile);
                if (pid != 0 && pid != -1)
-                       loginfox("sending signal %s to pid %d", siga, pid);
+                       loginfox("sending signal %s to pid %d", siga, (int)pid);
                if (pid == 0 || pid == -1 || kill(pid, sig) != 0) {
                        if (pid != 0 && pid != -1 && errno != ESRCH) {
                                logerr("kill");
@@ -2260,7 +2260,7 @@ printpidfile:
                        if (sig == SIGHUP || sig == SIGUSR1)
                                goto exit_success;
                        /* Spin until it exits */
-                       loginfox("waiting for pid %d to exit", pid);
+                       loginfox("waiting for pid %d to exit", (int)pid);
                        dhcpcd_pidfile_timeout(&ctx);
                        goto run_loop;
                }
@@ -2386,7 +2386,7 @@ printpidfile:
                        else
                                logerrx(PACKAGE
                                    " already running on pid %d (%s)",
-                                   pid, ctx.pidfile);
+                                   (int)pid, ctx.pidfile);
                        goto exit_failure;
                }
        }
@@ -2467,12 +2467,12 @@ printpidfile:
 
        /* We have now forked, setsid, forked once more.
         * From this point on, we are the controlling daemon. */
-       logdebugx("spawned manager process on PID %d", getpid());
+       logdebugx("spawned manager process on PID %d", (int)getpid());
 
 start_manager:
        ctx.options |= DHCPCD_STARTED;
        if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
-               logerr("%s: pidfile_lock %d", __func__, pid);
+               logerr("%s: pidfile_lock %d", __func__, (int)pid);
 #ifdef PRIVSEP
                /* privsep has not started ... */
                ctx.options &= ~DHCPCD_PRIVSEP;
index 94e6f4d9259730139c5a9d1d7f23d29d4ddd1400..c2c7a8e7d3fcc2b526e09497860b418eb7058180 100644 (file)
@@ -548,7 +548,7 @@ ipv4ll_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
            IN_ARE_ADDR_EQUAL(&state->addr->addr, &ia->addr))
        {
                loginfox("%s: pid %d deleted IP address %s",
-                   ifp->name, pid, ia->saddr);
+                   ifp->name, (int)pid, ia->saddr);
                ipv4ll_defend_failed(ifp);
                return ia;
        }
index 32b349bb6219c616055b70ecdef91b122bfecd8c..107e5988f8072d7b49db476bc5715f9c56bdd2c7 100644 (file)
@@ -1849,7 +1849,7 @@ ipv6_handleifa_addrs(int cmd,
 
                if (cmd == RTM_DELADDR && ia->flags & IPV6_AF_ADDED)
                        logwarnx("%s: pid %d deleted address %s",
-                           ia->iface->name, pid, ia->saddr);
+                           ia->iface->name, (int)pid, ia->saddr);
 
                /* Check DAD.
                 * On Linux we can get IN6_IFF_DUPLICATED via RTM_DELADDR. */
index a0c5d35f2af67d83e272ead835571b44e54c6150..98cd1c7e6c6299a20e0607c858372b2dda845c1a 100644 (file)
@@ -163,7 +163,7 @@ vlogprintf_r(struct logctx *ctx, FILE *stream, const char *fmt, va_list args)
                        pid = getpid();
                else
                        pid = ctx->log_pid;
-               if ((e = fprintf(stream, "[%d]", pid)) == -1)
+               if ((e = fprintf(stream, "[%d]", (int)pid)) == -1)
                        return -1;
                len += e;
        }
index 0037dda4ff0d832e58791aadde21f1e9fd37f1d8..cf3a70568575d227d4f25a4284c21012e5b4e609 100644 (file)
@@ -490,7 +490,7 @@ rt_recvrt(int cmd, const struct rt *rt, pid_t pid)
                        char buf[32];
 
                        rb_tree_remove_node(&ctx->routes, f);
-                       snprintf(buf, sizeof(buf), "pid %d deleted", pid);
+                       snprintf(buf, sizeof(buf), "pid %d deleted", (int)pid);
                        rt_desc(LOG_WARNING, buf, f);
                        rt_free(f);
                }
index abf62f60b197930368b556948076572f9bc79b01..0149aee9919f7360b9bec8be2a67625b1c015707 100644 (file)
@@ -279,7 +279,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
                if (efprintf(fp, "PATH=%s",
                    path == NULL ? DEFAULT_PATH : path) == -1)
                        goto eexit;
-               if (efprintf(fp, "pid=%d", getpid()) == -1)
+               if (efprintf(fp, "pid=%d", (int)getpid()) == -1)
                        goto eexit;
        }