From df818b9904af6141e2f9ba4cfff51886b0dbdf52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 20 Dec 2020 01:25:09 +0100 Subject: [PATCH 1/3] Use ATTR_UNUSED instead of void casting --- CRT.c | 3 +-- HostnameMeter.c | 3 +-- Meter.c | 4 +--- TraceScreen.c | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CRT.c b/CRT.c index aa115abe..56e9923f 100644 --- a/CRT.c +++ b/CRT.c @@ -652,8 +652,7 @@ int CRT_scrollWheelVAmount = 10; ColorScheme CRT_colorScheme = COLORSCHEME_DEFAULT; ATTR_NORETURN -static void CRT_handleSIGTERM(int sgn) { - (void) sgn; +static void CRT_handleSIGTERM(ATTR_UNUSED int sgn) { CRT_done(); _exit(0); } diff --git a/HostnameMeter.c b/HostnameMeter.c index af8e3493..0ba5183a 100644 --- a/HostnameMeter.c +++ b/HostnameMeter.c @@ -19,8 +19,7 @@ static const int HostnameMeter_attributes[] = { HOSTNAME }; -static void HostnameMeter_updateValues(Meter* this, char* buffer, size_t size) { - (void) this; +static void HostnameMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) { gethostname(buffer, size - 1); } diff --git a/Meter.c b/Meter.c index e8bfaad0..253fb4fb 100644 --- a/Meter.c +++ b/Meter.c @@ -387,9 +387,7 @@ static void LEDMeterMode_drawDigit(int x, int y, int n) { mvaddstr(y+i, x, LEDMeterMode_digits[i * 10 + n]); } -static void LEDMeterMode_draw(Meter* this, int x, int y, int w) { - (void) w; - +static void LEDMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED int w) { #ifdef HAVE_LIBNCURSESW if (CRT_utf8) LEDMeterMode_digits = LEDMeterMode_digitsUtf8; diff --git a/TraceScreen.c b/TraceScreen.c index c21e4802..50c0eca1 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -93,8 +93,7 @@ bool TraceScreen_forkTracer(TraceScreen* this) { // Should never reach here, unless execlp fails ... const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH."; - ssize_t written = write(STDERR_FILENO, message, strlen(message)); - (void) written; + (void)! write(STDERR_FILENO, message, strlen(message)); exit(127); } From 979aca98cc74d0d9420a63d148a1f9e8e9f89976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 2 Mar 2021 21:59:56 +0100 Subject: [PATCH 2/3] Use uppercase floating point literal suffix --- Process.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Process.c b/Process.c index 3fbcb634..58bd6a90 100644 --- a/Process.c +++ b/Process.c @@ -316,12 +316,12 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field if (field == PERCENT_NORM_CPU) { cpuPercentage /= this->processList->cpuCount; } - if (cpuPercentage > 999.9f) { + if (cpuPercentage > 999.9F) { xSnprintf(buffer, n, "%4u ", (unsigned int)cpuPercentage); - } else if (cpuPercentage > 99.9f) { + } else if (cpuPercentage > 99.9F) { xSnprintf(buffer, n, "%3u. ", (unsigned int)cpuPercentage); } else { - if (cpuPercentage < 0.05f) + if (cpuPercentage < 0.05F) attr = CRT_colors[PROCESS_SHADOW]; xSnprintf(buffer, n, "%4.1f ", cpuPercentage); @@ -329,10 +329,10 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field break; } case PERCENT_MEM: - if (this->percent_mem > 99.9f) { + if (this->percent_mem > 99.9F) { xSnprintf(buffer, n, "100. "); } else { - if (this->percent_mem < 0.05f) + if (this->percent_mem < 0.05F) attr = CRT_colors[PROCESS_SHADOW]; xSnprintf(buffer, n, "%4.1f ", this->percent_mem); From 13b28fa9ed283d9236ceb30f77e403cb451a7cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 2 Mar 2021 22:00:44 +0100 Subject: [PATCH 3/3] Enclose macro argument in parentheses --- linux/LinuxProcessList.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 69e5b75f..89a39732 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1546,7 +1546,7 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) { if (String_startsWith(buffer, label)) { \ memory_t parsed_; \ if (sscanf(buffer + strlen(label), "%llu kB", &parsed_) == 1) { \ - variable = parsed_; \ + (variable) = parsed_; \ } \ break; \ }