Skip to content

Commit

Permalink
core-*: use VOID_RET for return voidifications
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jun 11, 2022
1 parent 33c44ee commit 09b7eb5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 60 deletions.
4 changes: 1 addition & 3 deletions core-ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void stress_ftrace_add_pid(const pid_t pid)
char *path;
char buffer[32];
int fd;
ssize_t ret;

if (!(g_opt_flags & OPT_FLAGS_FTRACE))
return;
Expand All @@ -284,8 +283,7 @@ void stress_ftrace_add_pid(const pid_t pid)
} else {
snprintf(buffer, sizeof(buffer), "%" PRIdMAX , (intmax_t)pid);
}
ret = write(fd, buffer, strlen(buffer));
(void)ret;
VOID_RET(ssize_t, write(fd, buffer, strlen(buffer)));
(void)close(fd);
}

Expand Down
4 changes: 1 addition & 3 deletions core-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ static bool stress_lock_valid(stress_lock_t *lock)
void *stress_lock_create(void)
{
stress_lock_t *lock;
int ret;

errno = ENOMEM;
if (LOCK_METHOD_ALL == (0))
Expand Down Expand Up @@ -441,8 +440,7 @@ void *stress_lock_create(void)
if (lock->init(lock) == 0)
return lock;

ret = stress_lock_destroy(lock);
(void)ret;
VOID_RET(int, stress_lock_destroy(lock));

return NULL;

Expand Down
5 changes: 2 additions & 3 deletions core-madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void stress_madvise_pid_all_pages(const pid_t pid, const int advise)
return;
while (fgets(buf, sizeof(buf), fp)) {
void *start, *end, *offset;
int major, minor, n, ret;
int major, minor, n;
uint64_t inode;
char prot[5];

Expand All @@ -145,8 +145,7 @@ void stress_madvise_pid_all_pages(const pid_t pid, const int advise)
if (start >= end)
continue; /* invalid address range */

ret = madvise(start, (size_t)((uint8_t *)end - (uint8_t *)start), advise);
(void)ret;
VOID_RET(int, madvise(start, (size_t)((uint8_t *)end - (uint8_t *)start), advise));

/*
* Readable protection? read pages
Expand Down
3 changes: 1 addition & 2 deletions core-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ int stress_module_unload(
pr_dbg("%s: cannot unload %s, it is in use\n",
name, module_name);
}
ret = stress_module_unload_mod_and_deps(mod);
(void)ret;
VOID_RET(int, stress_module_unload_mod_and_deps(mod));
}

kmod_module_unref_list(list);
Expand Down
4 changes: 1 addition & 3 deletions core-out-of-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ int stress_oomable_child(
int status, ret;

(void)setpgid(pid, g_pgrp);

rewait:
ret = waitpid(pid, &status, 0);
if (ret < 0) {
Expand Down Expand Up @@ -318,8 +317,7 @@ int stress_oomable_child(

/* Explicitly drop capabilities, makes it more OOM-able */
if (flag & STRESS_OOMABLE_DROP_CAP) {
ret = stress_drop_capabilities(args->name);
(void)ret;
VOID_RET(int, stress_drop_capabilities(args->name));
}
if (!keep_stressing(args))
_exit(EXIT_SUCCESS);
Expand Down
5 changes: 1 addition & 4 deletions core-shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,10 +1087,7 @@ int shim_brk(void *addr)
#if defined(__APPLE__)
return (int)brk(addr);
#elif defined(__NR_brk)
int ret;

ret = (int)syscall(__NR_brk, addr);
(void)ret;
VOID_RET(int, (int)syscall(__NR_brk, addr));
return (errno == 0) ? 0 : ENOMEM;
#elif defined(HAVE_BRK)
return brk(addr);
Expand Down
41 changes: 10 additions & 31 deletions core-thrash.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ int stress_pagein_self(const char *name)

jmp_env_set = false;

ret = stress_sighandler(name, SIGBUS, stress_pagein_handler, &bus_action);
(void)ret;
ret = stress_sighandler(name, SIGSEGV, stress_pagein_handler, &segv_action);
(void)ret;
VOID_RET(int, stress_sighandler(name, SIGBUS, stress_pagein_handler, &bus_action));
VOID_RET(int, stress_sighandler(name, SIGSEGV, stress_pagein_handler, &segv_action));

ret = sigsetjmp(jmp_env, 1);
if (ret == 1)
Expand Down Expand Up @@ -181,13 +179,11 @@ static int stress_pagein_proc(const pid_t pid)
for (off = begin; thrash_run && (off < end); off += page_size) {
unsigned long data;
off_t pos;
ssize_t sz;

pos = lseek(fdmem, (off_t)off, SEEK_SET);
if (pos != (off_t)off)
continue;
sz = read(fdmem, &data, sizeof(data));
(void)sz;
VOID_RET(ssize_t, read(fdmem, &data, sizeof(data)));
}
}

Expand All @@ -205,13 +201,10 @@ static int stress_pagein_proc(const pid_t pid)
static inline void stress_compact_memory(void)
{
#if defined(__linux__)
ssize_t ret;

if (!thrash_run)
return;

ret = system_write("/proc/sys/vm/compact_memory", "1", 1);
(void)ret;
VOID_RET(ssize_t, system_write("/proc/sys/vm/compact_memory", "1", 1));
#endif
}

Expand All @@ -222,7 +215,6 @@ static inline void stress_compact_memory(void)
static inline void stress_zone_reclaim(void)
{
#if defined(__linux__)
ssize_t ret;
char mode[2];

if (!thrash_run)
Expand All @@ -231,8 +223,7 @@ static inline void stress_zone_reclaim(void)
mode[0] = '0' + (stress_mwc8() & 7);
mode[1] = '\0';

ret = system_write("/proc/sys/vm/zone_reclaim_mode", mode, 1);
(void)ret;
VOID_RET(ssize_t, system_write("/proc/sys/vm/zone_reclaim_mode", mode, 1));
#endif
}

Expand All @@ -245,13 +236,11 @@ static inline void stress_slab_shrink(void)
DIR *dir;
struct dirent *d;
static const char slabpath[] = "/sys/kernel/slab";
ssize_t ret;

/*
* older shrink interface, may fail
*/
ret = system_write("/sys/kernel/slab/cache/shrink", "1", 1);
(void)ret;
VOID_RET(ssize_t, system_write("/sys/kernel/slab/cache/shrink", "1", 1));

dir = opendir(slabpath);
if (!dir)
Expand All @@ -265,8 +254,7 @@ static inline void stress_slab_shrink(void)
char path[PATH_MAX];

(void)snprintf(path, sizeof(path), "%s/%s", slabpath, d->d_name);
ret = system_write(path, "1", 1);
(void)ret;
VOID_RET(ssize_t, system_write(path, "1", 1));
}
}
(void)closedir(dir);
Expand All @@ -281,14 +269,11 @@ static inline void stress_drop_caches(void)
#if defined(__linux__)
static int method = 0;
char str[3];
ssize_t ret;

str[0] = '1' + (char)method;
str[1] = '\0';

ret = system_write("/proc/sys/vm/drop_caches", str, 1);
(void)ret;

VOID_RET(ssize_t, system_write("/proc/sys/vm/drop_caches", str, 1));
if (method++ >= 2)
method = 0;
#endif
Expand All @@ -301,13 +286,10 @@ static inline void stress_drop_caches(void)
static inline void stress_merge_memory(void)
{
#if defined(__linux__)
ssize_t ret;

if (!thrash_run)
return;

ret = system_write("/proc/sys/mm/ksm/run", KSM_RUN_MERGE, 1);
(void)ret;
VOID_RET(ssize_t, system_write("/proc/sys/mm/ksm/run", KSM_RUN_MERGE, 1));
#endif
}

Expand Down Expand Up @@ -371,10 +353,7 @@ int stress_thrash_start(void)
return -1;
} else if (thrash_pid == 0) {
#if defined(SCHED_RR)
int ret;

ret = stress_set_sched(getpid(), SCHED_RR, 10, true);
(void)ret;
VOID_RET(int, stress_set_sched(getpid(), SCHED_RR, 10, true));
#endif
stress_set_proc_name("stress-ng-thrash");
if (stress_sighandler("main", SIGALRM, stress_thrash_handler, NULL) < 0)
Expand Down
8 changes: 3 additions & 5 deletions core-try-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ static void stress_try_kill(
int i;

for (i = 0; i < 10; i++) {
int ret, status;
int status;

ret = kill(pid, SIGKILL);
(void)ret;
ret = waitpid(pid, &status, WNOHANG);
(void)ret;
VOID_RET(int, kill(pid, SIGKILL));
VOID_RET(int, waitpid(pid, &status, WNOHANG));
if ((kill(pid, 0) < 0) && (errno == ESRCH))
return;
(void)shim_usleep(100000);
Expand Down
7 changes: 1 addition & 6 deletions core-vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,7 @@ void stress_vmstat_start(void)
#endif

#if defined(SCHED_DEADLINE)
{
int ret;

ret = stress_set_sched(getpid(), SCHED_DEADLINE, 99, true);
(void)ret;
}
VOID_RET(int, stress_set_sched(getpid(), SCHED_DEADLINE, 99, true));
#endif

while (keep_stressing_flag()) {
Expand Down

0 comments on commit 09b7eb5

Please sign in to comment.