From 09b7eb520b6e46a4025fff72fb88e49fc1616335 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 11 Jun 2022 13:52:43 +0000 Subject: [PATCH] core-*: use VOID_RET for return voidifications Signed-off-by: Colin Ian King --- core-ftrace.c | 4 +--- core-lock.c | 4 +--- core-madvise.c | 5 ++--- core-module.c | 3 +-- core-out-of-memory.c | 4 +--- core-shim.c | 5 +---- core-thrash.c | 41 ++++++++++------------------------------- core-try-open.c | 8 +++----- core-vmstat.c | 7 +------ 9 files changed, 21 insertions(+), 60 deletions(-) diff --git a/core-ftrace.c b/core-ftrace.c index 6bc487138..c84ef913f 100644 --- a/core-ftrace.c +++ b/core-ftrace.c @@ -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; @@ -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); } diff --git a/core-lock.c b/core-lock.c index 340df85ad..2a3f61202 100644 --- a/core-lock.c +++ b/core-lock.c @@ -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)) @@ -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; diff --git a/core-madvise.c b/core-madvise.c index 81251361c..3c87ffc27 100644 --- a/core-madvise.c +++ b/core-madvise.c @@ -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]; @@ -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 diff --git a/core-module.c b/core-module.c index 7e4cb3d3b..661b5cbfc 100644 --- a/core-module.c +++ b/core-module.c @@ -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); diff --git a/core-out-of-memory.c b/core-out-of-memory.c index 75eba8aef..80ebc4f8b 100644 --- a/core-out-of-memory.c +++ b/core-out-of-memory.c @@ -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) { @@ -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); diff --git a/core-shim.c b/core-shim.c index 1ff9f1a0f..a91f86432 100644 --- a/core-shim.c +++ b/core-shim.c @@ -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); diff --git a/core-thrash.c b/core-thrash.c index 41086f1d5..aa9083498 100644 --- a/core-thrash.c +++ b/core-thrash.c @@ -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) @@ -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))); } } @@ -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 } @@ -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) @@ -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 } @@ -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) @@ -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); @@ -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 @@ -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 } @@ -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) diff --git a/core-try-open.c b/core-try-open.c index 0119dfdb7..f7506b863 100644 --- a/core-try-open.c +++ b/core-try-open.c @@ -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); diff --git a/core-vmstat.c b/core-vmstat.c index 78ce4d5d7..c8125cdf6 100644 --- a/core-vmstat.c +++ b/core-vmstat.c @@ -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()) {