Skip to content

Commit 882614a

Browse files
committed
cast pid_t to int when used in format strings
Silences warnings on Solaris
1 parent 1893f35 commit 882614a

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

compat/pidfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ pidfile_lock(const char *path)
257257
* Then write the process ID. */
258258
if (ftruncate(pidfile_fd, 0) == -1 ||
259259
lseek(pidfile_fd, 0, SEEK_SET) == -1 ||
260-
dprintf(pidfile_fd, "%d\n", pidfile_pid) == -1)
260+
dprintf(pidfile_fd, "%d\n", (int)pidfile_pid) == -1)
261261
{
262262
int error = errno;
263263

src/dhcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4335,7 +4335,7 @@ dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
43354335
if (cmd == RTM_DELADDR) {
43364336
if (state->addr == ia) {
43374337
loginfox("%s: pid %d deleted IP address %s",
4338-
ifp->name, pid, ia->saddr);
4338+
ifp->name, (int)pid, ia->saddr);
43394339
dhcp_close(ifp);
43404340
state->addr = NULL;
43414341
/* Don't clear the added state as we need

src/dhcpcd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ dhcpcd_pidfile_timeout(void *arg)
18961896
if(pid == -1)
18971897
eloop_exit(ctx->eloop, EXIT_SUCCESS);
18981898
else if (++ctx->duid_len >= 100) { /* overload duid_len */
1899-
logerrx("pid %d failed to exit", pid);
1899+
logerrx("pid %d failed to exit", (int)pid);
19001900
eloop_exit(ctx->eloop, EXIT_FAILURE);
19011901
} else
19021902
eloop_timeout_add_msec(ctx->eloop, 100,
@@ -2247,7 +2247,7 @@ main(int argc, char **argv, char **envp)
22472247
if (sig != 0) {
22482248
pid = pidfile_read(ctx.pidfile);
22492249
if (pid != 0 && pid != -1)
2250-
loginfox("sending signal %s to pid %d", siga, pid);
2250+
loginfox("sending signal %s to pid %d", siga, (int)pid);
22512251
if (pid == 0 || pid == -1 || kill(pid, sig) != 0) {
22522252
if (pid != 0 && pid != -1 && errno != ESRCH) {
22532253
logerr("kill");
@@ -2260,7 +2260,7 @@ main(int argc, char **argv, char **envp)
22602260
if (sig == SIGHUP || sig == SIGUSR1)
22612261
goto exit_success;
22622262
/* Spin until it exits */
2263-
loginfox("waiting for pid %d to exit", pid);
2263+
loginfox("waiting for pid %d to exit", (int)pid);
22642264
dhcpcd_pidfile_timeout(&ctx);
22652265
goto run_loop;
22662266
}
@@ -2386,7 +2386,7 @@ main(int argc, char **argv, char **envp)
23862386
else
23872387
logerrx(PACKAGE
23882388
" already running on pid %d (%s)",
2389-
pid, ctx.pidfile);
2389+
(int)pid, ctx.pidfile);
23902390
goto exit_failure;
23912391
}
23922392
}
@@ -2467,12 +2467,12 @@ main(int argc, char **argv, char **envp)
24672467

24682468
/* We have now forked, setsid, forked once more.
24692469
* From this point on, we are the controlling daemon. */
2470-
logdebugx("spawned manager process on PID %d", getpid());
2470+
logdebugx("spawned manager process on PID %d", (int)getpid());
24712471

24722472
start_manager:
24732473
ctx.options |= DHCPCD_STARTED;
24742474
if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
2475-
logerr("%s: pidfile_lock %d", __func__, pid);
2475+
logerr("%s: pidfile_lock %d", __func__, (int)pid);
24762476
#ifdef PRIVSEP
24772477
/* privsep has not started ... */
24782478
ctx.options &= ~DHCPCD_PRIVSEP;

src/ipv4ll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ ipv4ll_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
548548
IN_ARE_ADDR_EQUAL(&state->addr->addr, &ia->addr))
549549
{
550550
loginfox("%s: pid %d deleted IP address %s",
551-
ifp->name, pid, ia->saddr);
551+
ifp->name, (int)pid, ia->saddr);
552552
ipv4ll_defend_failed(ifp);
553553
return ia;
554554
}

src/ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ ipv6_handleifa_addrs(int cmd,
18491849

18501850
if (cmd == RTM_DELADDR && ia->flags & IPV6_AF_ADDED)
18511851
logwarnx("%s: pid %d deleted address %s",
1852-
ia->iface->name, pid, ia->saddr);
1852+
ia->iface->name, (int)pid, ia->saddr);
18531853

18541854
/* Check DAD.
18551855
* On Linux we can get IN6_IFF_DUPLICATED via RTM_DELADDR. */

src/logerr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ vlogprintf_r(struct logctx *ctx, FILE *stream, const char *fmt, va_list args)
163163
pid = getpid();
164164
else
165165
pid = ctx->log_pid;
166-
if ((e = fprintf(stream, "[%d]", pid)) == -1)
166+
if ((e = fprintf(stream, "[%d]", (int)pid)) == -1)
167167
return -1;
168168
len += e;
169169
}

src/route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ rt_recvrt(int cmd, const struct rt *rt, pid_t pid)
490490
char buf[32];
491491

492492
rb_tree_remove_node(&ctx->routes, f);
493-
snprintf(buf, sizeof(buf), "pid %d deleted", pid);
493+
snprintf(buf, sizeof(buf), "pid %d deleted", (int)pid);
494494
rt_desc(LOG_WARNING, buf, f);
495495
rt_free(f);
496496
}

src/script.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
279279
if (efprintf(fp, "PATH=%s",
280280
path == NULL ? DEFAULT_PATH : path) == -1)
281281
goto eexit;
282-
if (efprintf(fp, "pid=%d", getpid()) == -1)
282+
if (efprintf(fp, "pid=%d", (int)getpid()) == -1)
283283
goto eexit;
284284
}
285285

0 commit comments

Comments
 (0)