Skip to content

Commit

Permalink
core-*: stress-*: replace %jd, %ju, %jx with PRIdMAX, PRIuMAX, PRIxMAX
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jan 22, 2025
1 parent 68fa38b commit 57096e9
Show file tree
Hide file tree
Showing 30 changed files with 83 additions and 81 deletions.
2 changes: 1 addition & 1 deletion core-affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ int stress_change_cpu(stress_args_t *args, const int old_cpu)
if (sched_setaffinity(0, sizeof(mask), &mask) >= 0) {
const int moved_cpu = (int)stress_get_cpu();
/*
pr_dbg("%s: process [%jd] (child of instance %d on CPU %u moved to CPU %u)\n",
pr_dbg("%s: process [%" PRIdMAX "] (child of instance %d on CPU %u moved to CPU %u)\n",
args->name, (intmax_t)getpid(), args->instance, from_cpu, moved_cpu);
*/
return moved_cpu;
Expand Down
14 changes: 7 additions & 7 deletions core-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2991,7 +2991,7 @@ int stress_drop_capabilities(const char *name)

ret = capget(&uch, ucd);
if (ret < 0) {
pr_fail("%s: capget on PID %jd failed: errno=%d (%s)\n",
pr_fail("%s: capget on PID %" PRIdMAX " failed: errno=%d (%s)\n",
name, (intmax_t)uch.pid, errno, strerror(errno));
return -1;
}
Expand All @@ -3012,7 +3012,7 @@ int stress_drop_capabilities(const char *name)

ret = capset(&uch, ucd);
if (ret < 0) {
pr_fail("%s: capset on PID %jd failed: errno=%d (%s)\n",
pr_fail("%s: capset on PID %" PRIdMAX " failed: errno=%d (%s)\n",
name, (intmax_t)uch.pid, errno, strerror(errno));
return -1;
}
Expand All @@ -3023,7 +3023,7 @@ int stress_drop_capabilities(const char *name)
if (ret < 0) {
/* Older kernels that don't support this prctl throw EINVAL */
if (errno != EINVAL) {
pr_inf("%s: prctl PR_SET_NO_NEW_PRIVS on PID %jd failed: "
pr_inf("%s: prctl PR_SET_NO_NEW_PRIVS on PID %" PRIdMAX " failed: "
"errno=%d (%s)\n",
name, (intmax_t)uch.pid, errno, strerror(errno));
}
Expand Down Expand Up @@ -3975,7 +3975,7 @@ const char *stress_get_fs_type(const char *filename)
if (fs_name) {
static char tmp[256];

(void)snprintf(tmp, sizeof(tmp), ", filesystem type: %s (%ju blocks available)",
(void)snprintf(tmp, sizeof(tmp), ", filesystem type: %s (%" PRIuMAX" blocks available)",
fs_name, blocks);
return tmp;
}
Expand Down Expand Up @@ -4610,7 +4610,7 @@ static void stress_dbg(const char *fmt, ...)
va_list ap;
int n, sz;
static char buf[256];
n = snprintf(buf, sizeof(buf), "stress-ng: debug: [%jd] ", (intmax_t)getpid());
n = snprintf(buf, sizeof(buf), "stress-ng: debug: [%" PRIdMAX"] ", (intmax_t)getpid());
if (n < 0)
return;
sz = n;
Expand Down Expand Up @@ -4946,7 +4946,7 @@ static void stress_process_info_dump(
if (!filename)
return;

(void)snprintf(path, sizeof(path), "/proc/%jd/%s", (intmax_t)pid, filename);
(void)snprintf(path, sizeof(path), "/proc/%" PRIdMAX "/%s", (intmax_t)pid, filename);
ret = stress_system_read(path, buf, sizeof(buf));
if (ret < 0)
return;
Expand Down Expand Up @@ -4974,7 +4974,7 @@ static void stress_process_info_dump(
if (ptr == end)
emit = begin;
if (emit) {
pr_dbg("%s: [%jd] %s: %s\n", args ? args->name : "main", (intmax_t)pid, filename, emit);
pr_dbg("%s: [%" PRIdMAX "] %s: %s\n", args ? args->name : "main", (intmax_t)pid, filename, emit);
emit = NULL;
}
}
Expand Down
4 changes: 2 additions & 2 deletions core-killpid.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int stress_wait_until_reaped(
* Process seems unkillable, report and bail out
*/
if (count > 600) {
pr_dbg("%s: cannot kill PID %jd after 10 minutes, giving up\n",
pr_dbg("%s: cannot kill PID %" PRIdMAX " after 10 minutes, giving up\n",
args->name, (intmax_t)pid);
stress_process_info(args, pid);
break;
Expand All @@ -142,7 +142,7 @@ int stress_kill_and_wait(
const pid_t mypid = getpid();

if ((pid == 0) || (pid == 1) || (pid == mypid)) {
pr_inf("%s: warning, attempt to kill PID %jd ignored\n",
pr_inf("%s: warning, attempt to kill PID %" PRIdMAX " ignored\n",
args->name, (intmax_t)pid);
}
/*
Expand Down
2 changes: 1 addition & 1 deletion core-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ int stress_set_sockaddr_if(
(void)shim_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
(void)snprintf(addr.sun_path, sizeof(addr.sun_path),
"/tmp/stress-ng-%jd-%" PRIu32,
"/tmp/stress-ng-%" PRIdMAX "-%" PRIu32,
(intmax_t)pid, instance);
*sockaddr = (struct sockaddr *)&addr;
*len = sizeof(addr);
Expand Down
2 changes: 1 addition & 1 deletion core-shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ pid_t shim_waitpid(pid_t pid, int *wstatus, int options)
* Process seems unkillable, report and bail out after 10 mins
*/
if (count > 600) {
pr_dbg("waitpid: SIGALRM on PID %jd has not resulted in "
pr_dbg("waitpid: SIGALRM on PID %" PRIdMAX" has not resulted in "
"process termination after 10 minutes, giving up\n",
(intmax_t)pid);
break;
Expand Down
2 changes: 1 addition & 1 deletion core-try-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void stress_try_kill(
return;
(void)shim_usleep(10000 * i);
}
pr_dbg("%s: can't kill PID %jd opening %s\n",
pr_dbg("%s: can't kill PID %" PRIdMAX " opening %s\n",
args->name, (intmax_t)pid, path);
stress_process_info(args, pid);
}
Expand Down
4 changes: 2 additions & 2 deletions stress-cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int stress_capgetset_pid(
if (ret < 0) {
if (((errno == ESRCH) && exists) ||
(errno != ESRCH)) {
pr_fail("%s: capget on PID %jd failed: errno=%d (%s)\n",
pr_fail("%s: capget on PID %" PRIdMAX " failed: errno=%d (%s)\n",
args->name, (intmax_t)pid, errno, strerror(errno));
return EXIT_FAILURE;
}
Expand All @@ -67,7 +67,7 @@ static int stress_capgetset_pid(
if (ret < 0) {
if (((errno == ESRCH) && exists) ||
(errno != ESRCH)) {
pr_fail("%s: capget on PID %jd failed: errno=%d (%s)\n",
pr_fail("%s: capget on PID %" PRIdMAX " failed: errno=%d (%s)\n",
args->name, (intmax_t)pid, errno, strerror(errno));
return EXIT_FAILURE;
}
Expand Down
10 changes: 5 additions & 5 deletions stress-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ static void stress_cgroup_add_pid(const char *realpathname, const pid_t pid)
char filename[PATH_MAX + 64], cmd[64];
ssize_t len;

len = (ssize_t)snprintf(cmd, sizeof(cmd), "%jd\n", (intmax_t)pid);
(void)snprintf(filename, sizeof(filename), "%s/stress-ng-%jd/cgroup.procs", realpathname, (intmax_t)pid);
len = (ssize_t)snprintf(cmd, sizeof(cmd), "%" PRIdMAX "\n", (intmax_t)pid);
(void)snprintf(filename, sizeof(filename), "%s/stress-ng-%" PRIdMAX "/cgroup.procs", realpathname, (intmax_t)pid);
stress_system_write(filename, cmd, len);
}

Expand All @@ -283,7 +283,7 @@ static void stress_cgroup_del_pid(const char *realpathname, const pid_t pid)
char filename[PATH_MAX + 64], cmd[64];
ssize_t len;

len = (ssize_t)snprintf(cmd, sizeof(cmd), "%jd\n", (intmax_t)pid);
len = (ssize_t)snprintf(cmd, sizeof(cmd), "%" PRIdMAX "\n", (intmax_t)pid);
(void)snprintf(filename, sizeof(filename), "%s/cgroup.procs", realpathname);
stress_system_write(filename, cmd, len);
}
Expand Down Expand Up @@ -403,7 +403,7 @@ static void stress_cgroup_new_group(const char *realpathname)
};

/* Parent, exercise child in the cgroup */
(void)snprintf(path, sizeof(path), "%s/stress-ng-%jd", realpathname, (intmax_t)pid);
(void)snprintf(path, sizeof(path), "%s/stress-ng-%" PRIdMAX, realpathname, (intmax_t)pid);
if (mkdir(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) {
stress_kill_pid_wait(pid, &status);
(void)rmdir(path); /* just in case */
Expand All @@ -417,7 +417,7 @@ static void stress_cgroup_new_group(const char *realpathname)
char filename[PATH_MAX + 64];

stress_cgroup_add_pid(realpathname, pid);
(void)snprintf(filename, sizeof(filename), "%s/stress-ng-%jd/%s", realpathname, (intmax_t)pid, values[i].name);
(void)snprintf(filename, sizeof(filename), "%s/stress-ng-%" PRIdMAX "/%s", realpathname, (intmax_t)pid, values[i].name);
stress_cgroup_read(filename);

if (values[i].value) {
Expand Down
2 changes: 1 addition & 1 deletion stress-copy-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int stress_copy_file(stress_args_t *args)
verify_ret = stress_copy_file_range_verify(fd_in, &off64_in,
fd_out, &off64_out, copy_ret);
if (verify_ret < 0) {
pr_fail("%s: copy_file_range verify failed, input offset=%jd, output offset=%jd\n",
pr_fail("%s: copy_file_range verify failed, input offset=%" PRIdMAX " output offset=%" PRIdMAX "\n",
args->name, (intmax_t)off64_in_orig, (intmax_t)off64_out_orig);
}
}
Expand Down
4 changes: 2 additions & 2 deletions stress-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int stress_dir_rename(
char new_filename[PATH_MAX];
char tmp[32];

(void)snprintf(tmp, sizeof(tmp), "rename-%" PRIu32 "-%jd", stress_mwc32(), (intmax_t)getpid());
(void)snprintf(tmp, sizeof(tmp), "rename-%" PRIu32 "-%" PRIdMAX, stress_mwc32(), (intmax_t)getpid());
stress_mk_filename(new_filename, sizeof(new_filename), path, tmp);

dp = opendir(path);
Expand Down Expand Up @@ -379,7 +379,7 @@ static int stress_dir_readdir(
int rc = 0, i, got_mask, all_mask;
struct dirent *entry;

(void)snprintf(dirpath, sizeof(dirpath), "%s/test-%jd-%" PRIu32, pathname,
(void)snprintf(dirpath, sizeof(dirpath), "%s/test-%" PRIdMAX "-%" PRIu32, pathname,
(intmax_t)getpid(), stress_mwc32());
if (mkdir(dirpath, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
pr_fail("%s: cannot mkdir %s, errno=%d (%s)\n",
Expand Down
8 changes: 4 additions & 4 deletions stress-fallocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ static int stress_fallocate(stress_args_t *args)
rc = EXIT_FAILURE;
}
else if (buf.st_size != fallocate_bytes) {
pr_fail("%s: file size %jd does not match size the expected file size of %jd\n",
pr_fail("%s: file size %" PRIdMAX " does not match "
"the expected file size of %" PRIdMAX "\n",
args->name, (intmax_t)buf.st_size,
(intmax_t)fallocate_bytes);
rc = EXIT_FAILURE;
Expand All @@ -202,9 +203,8 @@ static int stress_fallocate(stress_args_t *args)
rc = EXIT_FAILURE;
}
else if (buf.st_size != (off_t)0) {
pr_fail("%s: file size %jd does not "
"match size the expected file size "
"of 0\n",
pr_fail("%s: file size %" PRIdMAX " does not match "
"the expected file size " "of 0\n",
args->name, (intmax_t)buf.st_size);
rc = EXIT_FAILURE;
}
Expand Down
26 changes: 13 additions & 13 deletions stress-fsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int stress_fsize_boundary(
new_rlim.rlim_cur = offset;

if (setrlimit(RLIMIT_FSIZE, &new_rlim) < 0) {
pr_fail("%s: failed to set RLIMIT_FSIZE to %jd (0x%jx), errno=%d (%s)\n",
pr_fail("%s: failed to set RLIMIT_FSIZE to %" PRIdMAX " (0x%" PRIxMAX "), errno=%d (%s)\n",
args->name, (intmax_t)new_rlim.rlim_cur, (intmax_t)new_rlim.rlim_cur,
errno, strerror(errno));
}
Expand All @@ -110,15 +110,15 @@ static int stress_fsize_boundary(
ret = shim_fallocate(fd, 0, off, size);
if (ret < 0) {
if ((errno != EFBIG) && (errno != ENOSPC) && (errno != EINTR)) {
pr_fail("%s: fallocate failed at offset %jd (0x%jx) with unexpected error: %d (%s)\n",
pr_fail("%s: fallocate failed at offset %" PRIdMAX" (0x%" PRIxMAX ") with unexpected error: %d (%s)\n",
args->name, (intmax_t)off, (intmax_t)off,
errno, strerror(errno));
rc = EXIT_FAILURE;
}
return rc;
}
if (sigxfsz) {
pr_fail("%s: got an unexpected SIGXFSZ signal at offset %jd (0x%jx)\n",
pr_fail("%s: got an unexpected SIGXFSZ signal at offset %" PRIdMAX " (0x%" PRIxMAX ")\n",
args->name, (intmax_t)off, (intmax_t)off);
rc = EXIT_FAILURE;
}
Expand All @@ -128,18 +128,18 @@ static int stress_fsize_boundary(
ret = shim_fallocate(fd, 0, off, size);
if (ret == 0) {
if (!stress_fsize_reported(off, FSIZE_TYPE_FALLOC)) {
pr_inf("%s: fallocate unexpectedly succeeded at offset %jd (0x%jx), expecting EFBIG error\n",
pr_inf("%s: fallocate unexpectedly succeeded at offset %" PRIdMAX " (0x%" PRIxMAX "), expecting EFBIG error\n",
args->name, (intmax_t)off, (intmax_t)off);
}
return rc;
} else if ((errno != EFBIG) && (errno != ENOSPC) && (errno != EINTR)) {
pr_fail("%s: fallocate failed at offset %jd (0x%jx) with unexpected error: %d (%s)\n",
pr_fail("%s: fallocate failed at offset %" PRIdMAX" (0x%" PRIxMAX ") with unexpected error: %d (%s)\n",
args->name, (intmax_t)off, (intmax_t)off,
errno, strerror(errno));
return EXIT_FAILURE;
}
if (!sigxfsz && !stress_fsize_reported(off, FSIZE_TYPE_SIGXFSZ)) {
pr_inf("%s: did not get expected SIGXFSZ signal at offset %jd (0x%jx)\n",
pr_inf("%s: did not get expected SIGXFSZ signal at offset %" PRIdMAX " (0x%" PRIxMAX ")\n",
args->name, (intmax_t)off, (intmax_t)off);
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -215,7 +215,7 @@ static int stress_fsize(stress_args_t *args)
new_rlim.rlim_max = old_rlim.rlim_max;

if (setrlimit(RLIMIT_FSIZE, &new_rlim) < 0) {
pr_fail("%s: failed to set RLIMIT_FSIZE to %jd (0x%jx), errno=%d (%s)\n",
pr_fail("%s: failed to set RLIMIT_FSIZE to %" PRIdMAX " (0x%" PRIxMAX "), errno=%d (%s)\n",
args->name, (intmax_t)max, (intmax_t)max, errno, strerror(errno));
}

Expand All @@ -233,13 +233,13 @@ static int stress_fsize(stress_args_t *args)
if (shim_fallocate(fd, 0, 0, (off_t)max) < 0) {
if ((errno == ENOSPC) || (errno == EINTR)) {
/* No resource */
pr_inf_skip("%s: allocating file to %jd (0x%jx) bytes failed, errno=%d (%s), "
pr_inf_skip("%s: allocating file to %" PRIdMAX " (0x%" PRIxMAX ") bytes failed, errno=%d (%s), "
"skipping stressor\n", args->name, (intmax_t)max, (intmax_t)max,
errno, strerror(errno));
rc = EXIT_NO_RESOURCE;
} else {
/* A real issue, report it */
pr_inf("%s: allocating file to %jd bytes (0x%jx) failed, errno=%d (%s), "
pr_inf("%s: allocating file to %" PRIdMAX " bytes (0x%" PRIxMAX ") failed, errno=%d (%s), "
"terminating stressor\n", args->name, (intmax_t)max, (intmax_t)max,
errno, strerror(errno));
rc = EXIT_FAILURE;
Expand All @@ -248,16 +248,16 @@ static int stress_fsize(stress_args_t *args)
}
sigxfsz = false;
if (shim_fallocate(fd, 0, (off_t)max, 4096) == 0) {
pr_fail("%s: fallocate unexpectedly succeeded at offset %jd (0x%jx), expecting EFBIG error\n",
pr_fail("%s: fallocate unexpectedly succeeded at offset %" PRIdMAX " (0x%" PRIxMAX "), expecting EFBIG error\n",
args->name, (intmax_t)max, (intmax_t)max);
rc = EXIT_FAILURE;
} else if ((errno != EFBIG) && (errno != ENOSPC) && (errno != EINTR)) {
pr_fail("%s: failed at offset %jd (0x%jx) with unexpected error: %d (%s)\n",
pr_fail("%s: failed at offset %" PRIdMAX " (0x%" PRIxMAX ") with unexpected error: %d (%s)\n",
args->name, (intmax_t)max, (intmax_t)max, errno, strerror(errno) );
rc = EXIT_FAILURE;
}
if (!sigxfsz) {
pr_fail("%s: expected a SIGXFSZ signal at offset %jd (0x%jx), nothing happened\n",
pr_fail("%s: expected a SIGXFSZ signal at offset %" PRIdMAX " (0x%" PRIxMAX "), nothing happened\n",
args->name, (intmax_t)max, (intmax_t)max);
rc = EXIT_FAILURE;
}
Expand All @@ -280,7 +280,7 @@ static int stress_fsize(stress_args_t *args)
/* Should be able to set back to original size */
new_rlim = old_rlim;
if (setrlimit(RLIMIT_FSIZE, &new_rlim) < 0) {
pr_fail("%s: failed to set RLIMIT_FSIZE to %jd (0x%jx), errno=%d (%s)\n",
pr_fail("%s: failed to set RLIMIT_FSIZE to %" PRIdMAX " (0x%" PRIxMAX "), errno=%d (%s)\n",
args->name, (intmax_t)new_rlim.rlim_cur, (intmax_t)new_rlim.rlim_cur,
errno, strerror(errno));
rc = EXIT_FAILURE;
Expand Down
4 changes: 2 additions & 2 deletions stress-full.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static int stress_full(stress_args_t *args)
(off_t)(stress_mwc32() & 0x7fffffffUL);
ret = pread(fd, buffer, buffer_size, offset);
if (UNLIKELY(ret < 0)) {
pr_fail("%s: read failed at offset %jd, errno=%d (%s)\n",
pr_fail("%s: read failed at offset %" PRIdMAX ", errno=%d (%s)\n",
args->name, (intmax_t)offset, errno, strerror(errno));
goto fail;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ static int stress_full(stress_args_t *args)
offset = (off_t)stress_mwc64();
ret = lseek(fd, offset, whences[w].whence);
if (ret < 0) {
pr_fail("%s: lseek(fd, %jd, %s) failed, errno=%d (%s)\n",
pr_fail("%s: lseek(fd, %" PRIdMAX ", %s) failed, errno=%d (%s)\n",
args->name, (intmax_t)offset, whences[w].name,
errno, strerror(errno));
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion stress-iomix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ static int stress_iomix(stress_args_t *args)
} while ((ret < 0) && stress_continue(args));

if (iomix_bytes_shrunk)
pr_inf("%s: file size too large for file system, reducing file size to %jd MB\n",
pr_inf("%s: file size too large for file system, reducing file size to %" PRIdMAX " MB\n",
args->name, (intmax_t)iomix_bytes >> 20);

stress_file_rw_hint_short(fd);
Expand Down
4 changes: 2 additions & 2 deletions stress-kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int stress_kill(stress_args_t *args)
errno = saved_errno;
}
if ((ret < 0) && (g_opt_flags & OPT_FLAGS_VERIFY))
pr_fail("%s: kill PID %jd with SIGUSR1 failed, errno=%d (%s)\n",
pr_fail("%s: kill PID %" PRIdMAX " with SIGUSR1 failed, errno=%d (%s)\n",
args->name, (intmax_t)args->pid, errno, strerror(errno));

/* Zero signal can be used to see if process exists */
Expand All @@ -106,7 +106,7 @@ static int stress_kill(stress_args_t *args)
errno = saved_errno;
}
if ((ret < 0) && (g_opt_flags & OPT_FLAGS_VERIFY))
pr_fail("%s: kill PID %jd with signal 0 failed, errno=%d (%s)\n",
pr_fail("%s: kill PID %" PRIdMAX " with signal 0 failed, errno=%d (%s)\n",
args->name, (intmax_t)args->pid, errno, strerror(errno));

/*
Expand Down
4 changes: 2 additions & 2 deletions stress-metamix.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int stress_metamix_file(
}

if ((intmax_t)statbuf.st_size != (intmax_t)end) {
pr_fail("%s: stat on %s, expecting file size %jd, got %jd\n",
pr_fail("%s: stat on %s, expecting file size %" PRIdMAX ", got %" PRIdMAX "\n",
args->name, filename, (intmax_t)end, (intmax_t)statbuf.st_size);
rc = EXIT_FAILURE;
goto err_unlink;
Expand Down Expand Up @@ -294,7 +294,7 @@ static int stress_metamix_file(
goto err_close;
}
if ((intmax_t)statbuf.st_size != (intmax_t)end) {
pr_fail("%s: stat on %s, expecting file size %jd, got %jd\n",
pr_fail("%s: stat on %s, expecting file size %" PRIdMAX ", got %" PRIdMAX "\n",
args->name, filename, (intmax_t)end, (intmax_t)statbuf.st_size);
rc = EXIT_FAILURE;
goto err_close;
Expand Down
Loading

0 comments on commit 57096e9

Please sign in to comment.