add_key.2, clock_getres.2, clone.2, futex.2, getdents.2, getpid.2, getrlimit.2, ioctl_ns.2, kcmp.2, keyctl.2, memfd_create.2, request_key.2, stat.2, timer_create.2, wait.2, clock_getcpuclockid.3, dl_iterate_phdr.3, getgrent_r.3, getpwent_r.3, getpwnam.3, posix_spawn.3, pthread_getcpuclockid.3, strcat.3, feature_test_macros.7, user_namespaces.7: Switch printf() casts to use [u]intmax_t + %ju / %jd

Let's move to the 21st century. Instead of casting system data
types to long/long long/etc. in printf() calls, instead cast to
intmax_t or uintmax_t, the largest available signed/unsigned
integer types.

[mtk: rewrote commit message]

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Alejandro Colomar 2020-09-14 10:44:59 +02:00 committed by Michael Kerrisk
parent 6fd153d540
commit 8eb90116f1
25 changed files with 114 additions and 82 deletions

View File

@ -240,6 +240,7 @@ $ \fBgrep \(aq64a4dca\(aq /proc/keys\fP
.EX
#include <sys/types.h>
#include <keyutils.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -262,7 +263,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("Key ID is %lx\en", (unsigned long) key);
printf("Key ID is %jx\en", (uintmax_t) key);
exit(EXIT_SUCCESS);
}

View File

@ -467,6 +467,7 @@ CLOCK_BOOTTIME : 72691.019 (20h 11m 31s)
*/
#define _XOPEN_SOURCE 600
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@ -484,8 +485,8 @@ displayClock(clockid_t clock, char *name, bool showRes)
exit(EXIT_FAILURE);
}
printf("%\-15s: %10ld.%03ld (", name,
(long) ts.tv_sec, ts.tv_nsec / 1000000);
printf("%\-15s: %10jd.%03ld (", name,
(intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
long days = ts.tv_sec / SECS_IN_DAY;
if (days > 0)
@ -503,8 +504,8 @@ displayClock(clockid_t clock, char *name, bool showRes)
}
if (showRes)
printf(" resolution: %10ld.%09ld\en",
(long) ts.tv_sec, ts.tv_nsec);
printf(" resolution: %10jd.%09ld\en",
(intmax_t) ts.tv_sec, ts.tv_nsec);
}
int

View File

@ -1802,6 +1802,7 @@ so we should include it for portability.
#include <sys/utsname.h>
#include <sched.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -1865,7 +1866,7 @@ main(int argc, char *argv[])
pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);
if (pid == \-1)
errExit("clone");
printf("clone() returned %ld\en", (long) pid);
printf("clone() returned %jd\en", (intmax_t) pid);
/* Parent falls through to here */

View File

@ -1753,6 +1753,7 @@ Child (18535) 4
#include <stdio.h>
#include <errno.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
@ -1860,7 +1861,7 @@ main(int argc, char *argv[])
if (childPid == 0) { /* Child */
for (int j = 0; j < nloops; j++) {
fwait(futex1);
printf("Child (%ld) %d\en", (long) getpid(), j);
printf("Child (%jd) %d\en", (intmax_t) getpid(), j);
fpost(futex2);
}
@ -1871,7 +1872,7 @@ main(int argc, char *argv[])
for (int j = 0; j < nloops; j++) {
fwait(futex2);
printf("Parent (%ld) %d\en", (long) getpid(), j);
printf("Parent (%jd) %d\en", (intmax_t) getpid(), j);
fpost(futex1);
}

View File

@ -256,6 +256,7 @@ inode# file type d_reclen d_off d_name
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -307,8 +308,8 @@ main(int argc, char *argv[])
(d_type == DT_LNK) ? "symlink" :
(d_type == DT_BLK) ? "block dev" :
(d_type == DT_CHR) ? "char dev" : "???");
printf("%4d %10lld %s\en", d\->d_reclen,
(long long) d\->d_off, d\->d_name);
printf("%4d %10jd %s\en", d\->d_reclen,
(intmax_t) d\->d_off, d\->d_name);
bpos += d\->d_reclen;
}
}

View File

@ -97,6 +97,7 @@ in the child would return the wrong value
.\" #define _GNU_SOURCE
.\" #include <sys/syscall.h>
.\" #include <sys/wait.h>
.\" #include <stdint.h>
.\" #include <stdio.h>
.\" #include <stdlib.h>
.\" #include <unistd.h>
@ -106,13 +107,13 @@ in the child would return the wrong value
.\" {
.\" /* The following statement fills the getpid() cache */
.\"
.\" printf("parent PID = %ld\n", (long) getpid());
.\" printf("parent PID = %ld\n", (intmax_t) getpid());
.\"
.\" if (syscall(SYS_fork) == 0) {
.\" if (getpid() != syscall(SYS_getpid))
.\" printf("child getpid() mismatch: getpid()=%ld; "
.\" printf("child getpid() mismatch: getpid()=%jd; "
.\" "syscall(SYS_getpid)=%ld\n",
.\" (long) getpid(), (long) syscall(SYS_getpid));
.\" (intmax_t) getpid(), (long) syscall(SYS_getpid));
.\" exit(EXIT_SUCCESS);
.\" }
.\" wait(NULL);

View File

@ -783,6 +783,7 @@ The program below demonstrates the use of
.EX
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
@ -819,15 +820,15 @@ main(int argc, char *argv[])
if (prlimit(pid, RLIMIT_CPU, newp, &old) == \-1)
errExit("prlimit\-1");
printf("Previous limits: soft=%lld; hard=%lld\en",
(long long) old.rlim_cur, (long long) old.rlim_max);
printf("Previous limits: soft=%jd; hard=%jd\en",
(intmax_t) old.rlim_cur, (intmax_t) old.rlim_max);
/* Retrieve and display new CPU time limit */
if (prlimit(pid, RLIMIT_CPU, NULL, &old) == \-1)
errExit("prlimit\-2");
printf("New limits: soft=%lld; hard=%lld\en",
(long long) old.rlim_cur, (long long) old.rlim_max);
printf("New limits: soft=%jd; hard=%jd\en",
(intmax_t) old.rlim_cur, (intmax_t) old.rlim_max);
exit(EXIT_SUCCESS);
}

View File

@ -254,6 +254,7 @@ The owning user namespace is outside your namespace scope
Licensed under the GNU General Public License v2 or later.
*/
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@ -316,10 +317,10 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("Device/Inode of owning user namespace is: "
"[%lx,%lx] / %ld\en",
(unsigned long) major(sb.st_dev),
(unsigned long) minor(sb.st_dev),
(long) sb.st_ino);
"[%jx,%jx] / %jd\en",
(uintmax_t) major(sb.st_dev),
(uintmax_t) minor(sb.st_dev),
(intmax_t) sb.st_ino);
close(userns_fd);
}
@ -346,10 +347,10 @@ main(int argc, char *argv[])
perror("fstat\-parentns");
exit(EXIT_FAILURE);
}
printf("Device/Inode of parent namespace is: [%lx,%lx] / %ld\en",
(unsigned long) major(sb.st_dev),
(unsigned long) minor(sb.st_dev),
(long) sb.st_ino);
printf("Device/Inode of parent namespace is: [%jx,%jx] / %jd\en",
(uintmax_t) major(sb.st_dev),
(uintmax_t) minor(sb.st_dev),
(intmax_t) sb.st_ino);
close(parent_fd);
}

View File

@ -352,6 +352,7 @@ Child duplicated FD 3 to create FD 5
#include <sys/syscall.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -372,8 +373,8 @@ static void
test_kcmp(char *msg, id_t pid1, pid_t pid2, int fd_a, int fd_b)
{
printf("\et%s\en", msg);
printf("\et\etkcmp(%ld, %ld, KCMP_FILE, %d, %d) ==> %s\en",
(long) pid1, (long) pid2, fd_a, fd_b,
printf("\et\etkcmp(%jd, %jd, KCMP_FILE, %d, %d) ==> %s\en",
(intmax_t) pid1, (intmax_t) pid2, fd_a, fd_b,
(kcmp(pid1, pid2, KCMP_FILE, fd_a, fd_b) == 0) ?
"same" : "different");
}
@ -388,7 +389,7 @@ main(int argc, char *argv[])
if (fd1 == \-1)
errExit("open");
printf("Parent PID is %ld\en", (long) getpid());
printf("Parent PID is %jd\en", (intmax_t) getpid());
printf("Parent opened file on FD %d\en\en", fd1);
switch (fork()) {
@ -396,7 +397,7 @@ main(int argc, char *argv[])
errExit("fork");
case 0:
printf("PID of child of fork() is %ld\en", (long) getpid());
printf("PID of child of fork() is %jd\en", (intmax_t) getpid());
test_kcmp("Compare duplicate FDs from different processes:",
getpid(), getppid(), fd1, fd1);

View File

@ -2080,6 +2080,7 @@ $ \fBcat /proc/keys | egrep \(aqmykey|256e6a6\(aq\fP
#include <keyutils.h>
#include <time.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -2129,13 +2130,16 @@ main(int argc, char *argv[])
fprintf(fp, "Command line arguments:\en");
fprintf(fp, " argv[0]: %s\en", argv[0]);
fprintf(fp, " operation: %s\en", operation);
fprintf(fp, " key_to_instantiate: %lx\en",
(long) key_to_instantiate);
fprintf(fp, " UID: %ld\en", (long) uid);
fprintf(fp, " GID: %ld\en", (long) gid);
fprintf(fp, " thread_keyring: %lx\en", (long) thread_keyring);
fprintf(fp, " process_keyring: %lx\en", (long) process_keyring);
fprintf(fp, " session_keyring: %lx\en", (long) session_keyring);
fprintf(fp, " key_to_instantiate: %jx\en",
(uintmax_t) key_to_instantiate);
fprintf(fp, " UID: %jd\en", (intmax_t) uid);
fprintf(fp, " GID: %jd\en", (intmax_t) gid);
fprintf(fp, " thread_keyring: %jx\en",
(uintmax_t) thread_keyring);
fprintf(fp, " process_keyring: %jx\en",
(uintmax_t) process_keyring);
fprintf(fp, " session_keyring: %jx\en",
(uintmax_t) session_keyring);
fprintf(fp, "\en");
/*
@ -2184,7 +2188,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fprintf(fp, "Auth key ID: %lx\en", (long) auth_key);
fprintf(fp, "Auth key ID: %jx\en", (uintmax_t) auth_key);
/*
* Fetch key ID for the request_key(2) destination keyring.
@ -2197,7 +2201,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fprintf(fp, "Destination keyring: %lx\en", (long) dest_keyring);
fprintf(fp, "Destination keyring: %jx\en", (uintmax_t) dest_keyring);
/*
* Fetch the description of the authorization key. This

View File

@ -407,6 +407,7 @@ Existing seals: WRITE SHRINK
\&
.EX
#define _GNU_SOURCE
#include <stdint.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
@ -454,8 +455,8 @@ main(int argc, char *argv[])
if (ftruncate(fd, len) == \-1)
errExit("truncate");
printf("PID: %ld; fd: %d; /proc/%ld/fd/%d\en",
(long) getpid(), fd, (long) getpid(), fd);
printf("PID: %jd; fd: %d; /proc/%jd/fd/%d\en",
(intmax_t) getpid(), fd, (intmax_t) getpid(), fd);
/* Code to map the file and populate the mapping with data
omitted */

View File

@ -515,6 +515,7 @@ For another example of the use of this program, see
#include <sys/types.h>
#include <keyutils.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -537,7 +538,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("Key ID is %lx\en", (unsigned long) key);
printf("Key ID is %jx\en", (uintmax_t) key);
exit(EXIT_SUCCESS);
}

View File

@ -644,6 +644,7 @@ structure.
.EX
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
@ -664,9 +665,9 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("ID of containing device: [%lx,%lx]\en",
(unsigned long) major(sb.st_dev),
(unsigned long) minor(sb.st_dev));
printf("ID of containing device: [%jx,%jx]\en",
(uintmax_t) major(sb.st_dev),
(uintmax_t) minor(sb.st_dev));
printf("File type: ");
@ -681,21 +682,21 @@ main(int argc, char *argv[])
default: printf("unknown?\en"); break;
}
printf("I\-node number: %ld\en", (long) sb.st_ino);
printf("I\-node number: %jd\en", (intmax_t) sb.st_ino);
printf("Mode: %lo (octal)\en",
(unsigned long) sb.st_mode);
printf("Mode: %jo (octal)\en",
(uintmax_t) sb.st_mode);
printf("Link count: %ld\en", (long) sb.st_nlink);
printf("Ownership: UID=%ld GID=%ld\en",
(long) sb.st_uid, (long) sb.st_gid);
printf("Link count: %jd\en", (intmax_t) sb.st_nlink);
printf("Ownership: UID=%jd GID=%jd\en",
(intmax_t) sb.st_uid, (intmax_t) sb.st_gid);
printf("Preferred I/O block size: %ld bytes\en",
(long) sb.st_blksize);
printf("File size: %lld bytes\en",
(long long) sb.st_size);
printf("Blocks allocated: %lld\en",
(long long) sb.st_blocks);
printf("Preferred I/O block size: %jd bytes\en",
(intmax_t) sb.st_blksize);
printf("File size: %jd bytes\en",
(intmax_t) sb.st_size);
printf("Blocks allocated: %jd\en",
(intmax_t) sb.st_blocks);
printf("Last status change: %s", ctime(&sb.st_ctime));
printf("Last file access: %s", ctime(&sb.st_atime));

View File

@ -369,6 +369,7 @@ Caught signal 34
.SS Program source
\&
.EX
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@ -390,7 +391,7 @@ print_siginfo(siginfo_t *si)
tidp = si\->si_value.sival_ptr;
printf(" sival_ptr = %p; ", si\->si_value.sival_ptr);
printf(" *sival_ptr = %#lx\en", (unsigned long) *tidp);
printf(" *sival_ptr = %#jx\en", (uintmax_t) *tidp);
or = timer_getoverrun(*tidp);
if (or == \-1)
@ -454,7 +455,7 @@ main(int argc, char *argv[])
if (timer_create(CLOCKID, &sev, &timerid) == \-1)
errExit("timer_create");
printf("timer ID is %#lx\en", (unsigned long) timerid);
printf("timer ID is %#jx\en", (uintmax_t) timerid);
/* Start the timer */

View File

@ -657,6 +657,7 @@ $
\&
.EX
#include <sys/wait.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@ -674,7 +675,7 @@ main(int argc, char *argv[])
}
if (cpid == 0) { /* Code executed by child */
printf("Child PID is %ld\en", (long) getpid());
printf("Child PID is %jd\en", (intmax_t) getpid());
if (argc == 1)
pause(); /* Wait for signals */
_exit(atoi(argv[1]));

View File

@ -127,6 +127,7 @@ CPU-time clock for PID 1 is 2.213466748 seconds
\&
.EX
#define _XOPEN_SOURCE 600
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -153,8 +154,8 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("CPU-time clock for PID %s is %ld.%09ld seconds\en",
argv[1], (long) ts.tv_sec, ts.tv_nsec);
printf("CPU-time clock for PID %s is %jd.%09ld seconds\en",
argv[1], (intmax_t) ts.tv_sec, ts.tv_nsec);
exit(EXIT_SUCCESS);
}
.EE

View File

@ -302,6 +302,7 @@ Name: "/lib64/ld-linux-x86-64.so.2" (7 segments)
#include <link.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
static int
callback(struct dl_phdr_info *info, size_t size, void *data)
@ -325,10 +326,10 @@ callback(struct dl_phdr_info *info, size_t size, void *data)
(p_type == PT_GNU_STACK) ? "PT_GNU_STACK" :
(p_type == PT_GNU_RELRO) ? "PT_GNU_RELRO" : NULL;
printf(" %2d: [%14p; memsz:%7lx] flags: %#x; ", j,
printf(" %2d: [%14p; memsz:%7jx] flags: %#jx; ", j,
(void *) (info\->dlpi_addr + info\->dlpi_phdr[j].p_vaddr),
info\->dlpi_phdr[j].p_memsz,
info\->dlpi_phdr[j].p_flags);
(uintmax_t) info\->dlpi_phdr[j].p_memsz,
(uintmax_t) info\->dlpi_phdr[j].p_flags);
if (type != NULL)
printf("%s\en", type);
else

View File

@ -174,6 +174,7 @@ in the stream with all other threads.
#define _GNU_SOURCE
#include <grp.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define BUFLEN 4096
@ -189,7 +190,7 @@ main(void)
i = getgrent_r(&grp, buf, sizeof(buf), &grpp);
if (i)
break;
printf("%s (%d):", grpp\->gr_name, grpp\->gr_gid);
printf("%s (%jd):", grpp\->gr_name, (intmax_t) grpp\->gr_gid);
for (int j = 0; ; j++) {
if (grpp\->gr_mem[j] == NULL)
break;

View File

@ -179,6 +179,7 @@ in the stream with all other threads.
#define _GNU_SOURCE
#include <pwd.h>
#include <stdio.h>
#include <stdint.h>
#define BUFLEN 4096
int
@ -194,8 +195,8 @@ main(void)
i = getpwent_r(&pw, buf, sizeof(buf), &pwp);
if (i)
break;
printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
printf("%s (%jd)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
(intmax_t) pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
}
endpwent();
exit(EXIT_SUCCESS);

View File

@ -283,6 +283,7 @@ supplied as a command-line argument.
.PP
.EX
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -323,7 +324,8 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
printf("Name: %s; UID: %ld\en", pwd.pw_gecos, (long) pwd.pw_uid);
printf("Name: %s; UID: %jd\en", pwd.pw_gecos,
(intmax_t) pwd.pw_uid);
exit(EXIT_SUCCESS);
}
.EE

View File

@ -682,6 +682,7 @@ Child status: exited, status=127
\&
.EX
#include <spawn.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -780,7 +781,7 @@ main(int argc, char *argv[])
errExitEN(s, "posix_spawn_file_actions_destroy");
}
printf("PID of child: %ld\en", (long) child_pid);
printf("PID of child: %jd\en", (intmax_t) child_pid);
/* Monitor status of the child until it terminates */

View File

@ -115,6 +115,7 @@ Subthread CPU time: 0.992
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
@ -143,7 +144,7 @@ pclock(char *msg, clockid_t cid)
printf("%s", msg);
if (clock_gettime(cid, &ts) == \-1)
handle_error("clock_gettime");
printf("%4ld.%03ld\en", ts.tv_sec, ts.tv_nsec / 1000000);
printf("%4jd.%03ld\en", (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
}
int

View File

@ -200,6 +200,7 @@ will provide better performance.)
.SS Program source
\&
.EX
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
@ -216,7 +217,7 @@ main(int argc, char *argv[])
for (int j = 0; j < LIM; j++) {
if ((j % 10000) == 0)
printf("%d %ld\en", j, (long) (time(NULL) \- base));
printf("%d %jd\en", j, (intmax_t) (time(NULL) \- base));
strcat(p, "a");
}
}

View File

@ -827,6 +827,7 @@ _GNU_SOURCE defined
.EX
/* ftm.c */
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -839,7 +840,8 @@ main(int argc, char *argv[])
#endif
#ifdef _POSIX_C_SOURCE
printf("_POSIX_C_SOURCE defined: %ldL\en", (long) _POSIX_C_SOURCE);
printf("_POSIX_C_SOURCE defined: %jdL\en",
(intmax_t) _POSIX_C_SOURCE);
#endif
#ifdef _ISOC99_SOURCE

View File

@ -1076,6 +1076,7 @@ CapEff: 0000001fffffffff
#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <signal.h>
@ -1190,8 +1191,8 @@ proc_setgroups_write(pid_t child_pid, char *str)
char setgroups_path[PATH_MAX];
int fd;
snprintf(setgroups_path, PATH_MAX, "/proc/%ld/setgroups",
(long) child_pid);
snprintf(setgroups_path, PATH_MAX, "/proc/%jd/setgroups",
(intmax_t) child_pid);
fd = open(setgroups_path, O_RDWR);
if (fd == \-1) {
@ -1323,16 +1324,17 @@ main(int argc, char *argv[])
/* Parent falls through to here */
if (verbose)
printf("%s: PID of child created by clone() is %ld\en",
argv[0], (long) child_pid);
printf("%s: PID of child created by clone() is %jd\en",
argv[0], (intmax_t) child_pid);
/* Update the UID and GID maps in the child */
if (uid_map != NULL || map_zero) {
snprintf(map_path, PATH_MAX, "/proc/%ld/uid_map",
(long) child_pid);
snprintf(map_path, PATH_MAX, "/proc/%jd/uid_map",
(intmax_t) child_pid);
if (map_zero) {
snprintf(map_buf, MAP_BUF_SIZE, "0 %ld 1", (long) getuid());
snprintf(map_buf, MAP_BUF_SIZE, "0 %jd 1",
(intmax_t) getuid());
uid_map = map_buf;
}
update_map(uid_map, map_path);
@ -1341,10 +1343,11 @@ main(int argc, char *argv[])
if (gid_map != NULL || map_zero) {
proc_setgroups_write(child_pid, "deny");
snprintf(map_path, PATH_MAX, "/proc/%ld/gid_map",
(long) child_pid);
snprintf(map_path, PATH_MAX, "/proc/%jd/gid_map",
(intmax_t) child_pid);
if (map_zero) {
snprintf(map_buf, MAP_BUF_SIZE, "0 %ld 1", (long) getgid());
snprintf(map_buf, MAP_BUF_SIZE, "0 %ld 1",
(intmax_t) getgid());
gid_map = map_buf;
}
update_map(gid_map, map_path);