Skip to content

Commit

Permalink
stress-*: use VOID_RET for return voidifications
Browse files Browse the repository at this point in the history
replace:
   type ret;

   ret = func();
   (void)ret;

with
   VOID_RET(type, func());

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jun 11, 2022
1 parent 55a964a commit 33c44ee
Show file tree
Hide file tree
Showing 138 changed files with 1,077 additions and 2,269 deletions.
11 changes: 4 additions & 7 deletions stress-access.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,13 @@ static int stress_access(const stress_args_t *args)
* first choice if it is possible.
*/
for (j = 0; j < SIZEOF_ARRAY(access_flags); j++) {
ret = shim_faccessat(AT_FDCWD, filename, modes[i].access_mode, access_flags[j]);
(void)ret;
VOID_RET(int, shim_faccessat(AT_FDCWD, filename, modes[i].access_mode, access_flags[j]));
}

/*
* Exercise bad dir_fd
*/
ret = shim_faccessat(bad_fd, filename, modes[i].access_mode, 0);
(void)ret;
VOID_RET(int, shim_faccessat(bad_fd, filename, modes[i].access_mode, 0));
#else
UNEXPECTED
#endif
Expand All @@ -233,9 +231,8 @@ static int stress_access(const stress_args_t *args)
/*
* Exercise bad dir_fd
*/
ret = faccessat2(bad_fd, filename, modes[i].access_mode,
AT_SYMLINK_NOFOLLOW);
(void)ret;
VOID_RET(int, faccessat2(bad_fd, filename, modes[i].access_mode,
AT_SYMLINK_NOFOLLOW));
#else
/* UNEXPECTED */
#endif
Expand Down
13 changes: 4 additions & 9 deletions stress-affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ static void stress_affinity_child(

do {
cpu_set_t mask;
int ret;

cpu = info->affinity_rand ? (stress_mwc32() >> 4) : cpu + 1;
cpu %= info->cpus;
Expand Down Expand Up @@ -221,20 +220,16 @@ static void stress_affinity_child(
}
}
/* Exercise getaffinity with invalid pid */
ret = sched_getaffinity(-1, sizeof(mask), &mask);
(void)ret;
VOID_RET(int, sched_getaffinity(-1, sizeof(mask), &mask));

/* Exercise getaffinity with mask size */
ret = sched_getaffinity(0, 0, &mask);
(void)ret;
VOID_RET(int, sched_getaffinity(0, 0, &mask));

/* Exercise setaffinity with invalid mask size */
ret = sched_setaffinity(0, 0, &mask);
(void)ret;
VOID_RET(int, sched_setaffinity(0, 0, &mask));

/* Exercise setaffinity with invalid mask */
ret = sched_setaffinity(0, sizeof(mask), &mask0);
(void)ret;
VOID_RET(int, sched_setaffinity(0, sizeof(mask), &mask0));

affinity_continue:
stress_lock_acquire(counter_lock);
Expand Down
42 changes: 14 additions & 28 deletions stress-aio-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,54 +567,44 @@ static int stress_aiol(const stress_args_t *args)

cancel = 0;

ret = shim_io_cancel(ctx, &cb[0], &event);
(void)ret;
VOID_RET(int, shim_io_cancel(ctx, &cb[0], &event));

/* Exercise with io_cancel invalid context */
(void)memset(&bad_ctx, stress_mwc8() | 0x1, sizeof(bad_ctx));
ret = shim_io_cancel(bad_ctx, &cb[0], &event);
(void)ret;
VOID_RET(int, shim_io_cancel(bad_ctx, &cb[0], &event));

/* Exercise with io_invalid iocb */
bad_iocb.aio_fildes = bad_fd;
bad_iocb.aio_lio_opcode = ~0;
bad_iocb.u.c.buf = NULL;
bad_iocb.u.c.offset = 0;
bad_iocb.u.c.nbytes = 0;
ret = shim_io_cancel(ctx, &bad_iocb, &event);
(void)ret;
VOID_RET(int, shim_io_cancel(ctx, &bad_iocb, &event));

/* Exercise io_destroy with illegal context, EINVAL */
ret = shim_io_destroy(bad_ctx);
(void)ret;
ret = shim_io_destroy(NULL);
(void)ret;
VOID_RET(int, shim_io_destroy(bad_ctx));
VOID_RET(int, shim_io_destroy(NULL));

/* Exercise io_getevents with illegal context, EINVAL */
timeout.tv_sec = 0;
timeout.tv_nsec = 100000;
ret = shim_io_getevents(bad_ctx, 1, 1, events, &timeout);
(void)ret;
VOID_RET(int, shim_io_getevents(bad_ctx, 1, 1, events, &timeout));

/* Exercise io_getevents with illegal min */
timeout.tv_sec = 0;
timeout.tv_nsec = 100000;
ret = shim_io_getevents(ctx, 1, 0, events, &timeout);
(void)ret;
ret = shim_io_getevents(ctx, -1, 0, events, &timeout);
(void)ret;
VOID_RET(int, shim_io_getevents(ctx, 1, 0, events, &timeout));
VOID_RET(int, shim_io_getevents(ctx, -1, 0, events, &timeout));

/* Exercise io_getevents with illegal nr */
timeout.tv_sec = 0;
timeout.tv_nsec = 100000;
ret = shim_io_getevents(ctx, 0, -1, events, &timeout);
(void)ret;
VOID_RET(int, shim_io_getevents(ctx, 0, -1, events, &timeout));

/* Exercise io_getevents with illegal timeout */
timeout.tv_sec = 0;
timeout.tv_nsec = ~0L;
ret = shim_io_getevents(ctx, 0, 1, events, &timeout);
(void)ret;
VOID_RET(int, shim_io_getevents(ctx, 0, 1, events, &timeout));

/* Exercise io_setup with illegal nr_events */
ret = shim_io_setup(0, &bad_ctx);
Expand All @@ -631,18 +621,14 @@ static int stress_aiol(const stress_args_t *args)
bad_iocb.u.c.offset = 0;
bad_iocb.u.c.nbytes = 0;
bad_iocbs[0] = &bad_iocb;
ret = shim_io_submit(bad_ctx, 1, bad_iocbs);
(void)ret;
VOID_RET(int, shim_io_submit(bad_ctx, 1, bad_iocbs));

/* Exercise io_submit with useless or illegal nr ios */
ret = shim_io_submit(ctx, 0, bad_iocbs);
(void)ret;
ret = shim_io_submit(ctx, -1, bad_iocbs);
(void)ret;
VOID_RET(int, shim_io_submit(ctx, 0, bad_iocbs));
VOID_RET(int, shim_io_submit(ctx, -1, bad_iocbs));

/* Exercise io_submit with illegal iocb */
ret = shim_io_submit(ctx, 1, bad_iocbs);
(void)ret;
VOID_RET(int, shim_io_submit(ctx, 1, bad_iocbs));
}
}
#else
Expand Down
5 changes: 1 addition & 4 deletions stress-bad-altstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ static void NORETURN MLOCKED_TEXT stress_signal_handler(int signum)
* while in this context. Not sure if this is portable
* so ignore this for now.
{
register int ret;
ret = stress_sigaltstack(stack, STRESS_MINSIGSTKSZ);
(void)ret;
VOID_RET(int, stress_sigaltstack(stack, STRESS_MINSIGSTKSZ));
}
*/

Expand Down
27 changes: 9 additions & 18 deletions stress-bad-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,57 +279,49 @@ static inline void stress_bad_ioctl_rw(

(void)memset(buf, 0, page_size);

ret = ioctl(fd, _IOR(type, nr, uint64_t), buf64);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint64_t), buf64));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint32_t), buf32);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint32_t), buf32));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint16_t), buf16);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint16_t), buf16));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint8_t), buf8);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint8_t), buf8));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, stress_4k_page_t), buf);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, stress_4k_page_t), buf));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint8_t), NULL);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint8_t), NULL));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint8_t), args->mapped->page_none);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint8_t), args->mapped->page_none));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
}

ret = ioctl(fd, _IOR(type, nr, uint8_t), args->mapped->page_ro);
(void)ret;
VOID_RET(int, ioctl(fd, _IOR(type, nr, uint8_t), args->mapped->page_ro));
if (stress_time_now() - t_start > threshold) {
(void)close(fd);
break;
Expand Down Expand Up @@ -492,8 +484,7 @@ static int stress_bad_ioctl(const stress_args_t *args)
pr_dbg("%s: failed to lock spin lock for dev_path\n", args->name);
} else {
dev_ioctl_node = NULL;
r = shim_pthread_spin_unlock(&lock);
(void)r;
VOID_RET(int, shim_pthread_spin_unlock(&lock));
}

for (i = 0; i < MAX_DEV_THREADS; i++) {
Expand Down
4 changes: 1 addition & 3 deletions stress-bind-mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ static int stress_bind_mount(const stress_args_t *args)
stress_set_proc_state(args->name, STRESS_STATE_RUN);

do {
int ret;
static char stack[CLONE_STACK_SIZE];
char *stack_top = (char *)stress_get_stack_top((void *)stack, CLONE_STACK_SIZE);

Expand All @@ -174,8 +173,7 @@ static int stress_bind_mount(const stress_args_t *args)
args->name, errno, strerror(errno));
return rc;
}
ret = shim_waitpid(pid, &status, 0);
(void)ret;
VOID_RET(int, shim_waitpid(pid, &status, 0));
} while (keep_stressing(args));

stress_set_proc_state(args->name, STRESS_STATE_DEINIT);
Expand Down
6 changes: 2 additions & 4 deletions stress-binderfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ static int stress_binderfs_umount(const stress_args_t *args, const char *pathnam
}

/* Exercise mount on already umounted path */
ret = umount(pathname);
(void)ret;
VOID_RET(int, umount(pathname));

/* Exercise mount on invalid path */
ret = umount("");
(void)ret;
VOID_RET(int, umount(""));

return EXIT_SUCCESS;
}
Expand Down
21 changes: 7 additions & 14 deletions stress-cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ static int stress_capgetset_pid(
* Exercise invalid pid -> EPERM
*/
uch.pid = INT_MIN;
ret = capset(&uch, ucd);
(void)ret;
VOID_RET(int, capset(&uch, ucd));

/*
* Exercise invalid version -> EINVAL
*/
uch.version = 0x1234dead;
uch.pid = pid;
ret = capset(&uch, ucd);
(void)ret;
VOID_RET(int, capset(&uch, ucd));
}
#else
UNEXPECTED
Expand All @@ -92,17 +90,15 @@ static int stress_capgetset_pid(
*/
uch.version = 0x1234dead;
uch.pid = pid;
ret = capget(&uch, ucd);
(void)ret;
VOID_RET(int, capget(&uch, ucd));

#if defined(_LINUX_CAPABILITY_VERSION_3)
/*
* Exercise invalid PID -> EINVAL
*/
uch.version = _LINUX_CAPABILITY_VERSION_3;
uch.pid = -pid;
ret = capget(&uch, ucd);
(void)ret;
VOID_RET(int, capget(&uch, ucd));
#else
UNEXPECTED
#endif
Expand All @@ -113,8 +109,7 @@ static int stress_capgetset_pid(
*/
uch.version = _LINUX_CAPABILITY_VERSION_3;
uch.pid = stress_get_unused_pid_racy(false);
ret = capget(&uch, ucd);
(void)ret;
VOID_RET(int, capget(&uch, ucd));
#else
UNEXPECTED
#endif
Expand All @@ -125,15 +120,13 @@ static int stress_capgetset_pid(
#if defined(_LINUX_CAPABILITY_VERSION_2)
uch.version = _LINUX_CAPABILITY_VERSION_2;
uch.pid = pid;
ret = capget(&uch, ucd);
(void)ret;
VOID_RET(int, capget(&uch, ucd));
#endif

#if defined(_LINUX_CAPABILITY_VERSION_1)
uch.version = _LINUX_CAPABILITY_VERSION_1;
uch.pid = pid;
ret = capget(&uch, ucd);
(void)ret;
VOID_RET(int, capget(&uch, ucd));
#endif

uch.version = ~0U;
Expand Down
16 changes: 5 additions & 11 deletions stress-chattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ static int do_chattr(
int fd, fdw, ret;
unsigned long zero = 0UL;
unsigned long orig, rnd;
ssize_t n;

fd = open(filename, O_RDONLY | O_NONBLOCK | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0)
Expand Down Expand Up @@ -115,8 +114,7 @@ static int do_chattr(
fdw = open(filename, O_RDWR);
if (fdw < 0)
goto tidy_fd;
n = write(fdw, &zero, sizeof(zero));
(void)n;
VOID_RET(ssize_t, write(fdw, &zero, sizeof(zero)));

if (!keep_stressing(args))
goto tidy_fdw;
Expand All @@ -129,30 +127,26 @@ static int do_chattr(

if (!keep_stressing(args))
goto tidy_fdw;
n = write(fdw, &zero, sizeof(zero));
(void)n;
VOID_RET(ssize_t, write(fdw, &zero, sizeof(zero)));

if (!keep_stressing(args))
goto tidy_fdw;
ret = ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &zero);
(void)ret;
VOID_RET(int, ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &zero));

/*
* Try some random flag, exercises any illegal flags
*/
if (!keep_stressing(args))
goto tidy_fdw;
rnd = 1ULL << (stress_mwc8() & 0x1f);
ret = ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &rnd);
(void)ret;
VOID_RET(int, ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &rnd));

/*
* Restore original setting
*/
if (!keep_stressing(args))
goto tidy_fdw;
ret = ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &orig);
(void)ret;
VOID_RET(int, ioctl(fd, SHIM_EXT2_IOC_SETFLAGS, &orig));
tidy_fdw:

(void)close(fdw);
Expand Down
Loading

0 comments on commit 33c44ee

Please sign in to comment.