diff options
author | Benny Baumann <BenBE@geshi.org> | 2022-10-22 19:19:39 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-10-24 23:13:22 +0200 |
commit | 40104588f38250afde9f71b6204d789039bbfe3e (patch) | |
tree | 745e532580371db2ca85b4ae57b10f1ad3396531 | |
parent | 4ad530d1c00f649dcd02b818a3ccc7ded0aaf12d (diff) |
Reformat code base
This includes:
- Wrap function implementations
- Pointer alignment for function signatures
- Pointer alignment for variable declarations
- Whitespace after keywords
- Whitespace after comma
- Whitespace around initializers
- Whitespace around operators
- Code indentation
- Line break for single line statements
- Misleading alignment
36 files changed, 191 insertions, 121 deletions
@@ -221,7 +221,7 @@ static Htop_Reaction actionToggleUserlandThreads(State* st) { return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING; } -static Htop_Reaction actionToggleRunningInContainer(State* st){ +static Htop_Reaction actionToggleRunningInContainer(State* st) { st->settings->hideRunningInContainer = !st->settings->hideRunningInContainer; return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING; } diff --git a/AffinityPanel.c b/AffinityPanel.c index 9875a5ce..b7243971 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -201,7 +201,7 @@ static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) { MaskItem* selected = (MaskItem*) Panel_getSelected(super); bool keepSelected = true; - switch(ch) { + switch (ch) { case KEY_MOUSE: case KEY_RECLICK: case ' ': diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index 7720bef4..b8c09c74 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -45,7 +45,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { AvailableColumnsPanel* this = (AvailableColumnsPanel*) super; HandlerResult result = IGNORED; - switch(ch) { + switch (ch) { case 13: case KEY_ENTER: case KEY_F(5): diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index 368f494f..c7ab89be 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -54,7 +54,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) { HandlerResult result = IGNORED; bool update = false; - switch(ch) { + switch (ch) { case KEY_F(5): case 'l': case 'L': diff --git a/AvailableMetersPanel.h b/AvailableMetersPanel.h index f5f7a2dd..1c0555af 100644 --- a/AvailableMetersPanel.h +++ b/AvailableMetersPanel.h @@ -29,6 +29,6 @@ typedef struct AvailableMetersPanel_ { extern const PanelClass AvailableMetersPanel_class; -AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, size_t columns, MetersPanel **meterPanels, ScreenManager* scr, const ProcessList* pl); +AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, size_t columns, MetersPanel** meterPanels, ScreenManager* scr, const ProcessList* pl); #endif @@ -187,7 +187,7 @@ static void CPUMeter_display(const Object* cast, RichString* out) { static void AllCPUsMeter_getRange(const Meter* this, int* start, int* count) { const CPUMeterData* data = this->meterData; unsigned int cpus = data->cpus; - switch(Meter_name(this)[0]) { + switch (Meter_name(this)[0]) { default: case 'A': // All *start = 0; @@ -195,10 +195,10 @@ static void AllCPUsMeter_getRange(const Meter* this, int* start, int* count) { break; case 'L': // First Half *start = 0; - *count = (cpus+1) / 2; + *count = (cpus + 1) / 2; break; case 'R': // Second Half - *start = (cpus+1) / 2; + *start = (cpus + 1) / 2; *count = cpus / 2; break; } @@ -408,11 +408,11 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, White), [CPU_STEAL] = ColorPair(Cyan, White), [CPU_GUEST] = ColorPair(Cyan, White), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Black,White), - [SCREENS_OTH_TEXT] = A_BOLD | ColorPair(Black,White), - [SCREENS_CUR_BORDER] = ColorPair(Green,Green), - [SCREENS_CUR_TEXT] = ColorPair(Black,Green), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Black, White), + [SCREENS_OTH_TEXT] = A_BOLD | ColorPair(Black, White), + [SCREENS_CUR_BORDER] = ColorPair(Green, Green), + [SCREENS_CUR_TEXT] = ColorPair(Black, Green), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black, White), [PRESSURE_STALL_SIXTY] = ColorPair(Black, White), [PRESSURE_STALL_TEN] = ColorPair(Black, White), @@ -515,11 +515,11 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, Black), [CPU_STEAL] = ColorPair(Black, Black), [CPU_GUEST] = ColorPair(Black, Black), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = ColorPair(Blue,Black), - [SCREENS_OTH_TEXT] = ColorPair(Blue,Black), - [SCREENS_CUR_BORDER] = ColorPair(Green,Green), - [SCREENS_CUR_TEXT] = ColorPair(Black,Green), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = ColorPair(Blue, Black), + [SCREENS_OTH_TEXT] = ColorPair(Blue, Black), + [SCREENS_CUR_BORDER] = ColorPair(Green, Green), + [SCREENS_CUR_TEXT] = ColorPair(Black, Green), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black, Black), [PRESSURE_STALL_SIXTY] = ColorPair(Black, Black), [PRESSURE_STALL_TEN] = ColorPair(Black, Black), @@ -622,11 +622,11 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Black, Blue), [CPU_STEAL] = ColorPair(White, Blue), [CPU_GUEST] = ColorPair(White, Blue), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Yellow,Blue), - [SCREENS_OTH_TEXT] = ColorPair(Cyan,Blue), - [SCREENS_CUR_BORDER] = ColorPair(Cyan,Cyan), - [SCREENS_CUR_TEXT] = ColorPair(Black,Cyan), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Yellow, Blue), + [SCREENS_OTH_TEXT] = ColorPair(Cyan, Blue), + [SCREENS_CUR_BORDER] = ColorPair(Cyan, Cyan), + [SCREENS_CUR_TEXT] = ColorPair(Black, Cyan), [PRESSURE_STALL_THREEHUNDRED] = A_BOLD | ColorPair(Black, Blue), [PRESSURE_STALL_SIXTY] = A_NORMAL | ColorPair(White, Blue), [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(White, Blue), @@ -727,11 +727,11 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, Black), [CPU_STEAL] = ColorPair(Cyan, Black), [CPU_GUEST] = ColorPair(Cyan, Black), - [PANEL_EDIT] = ColorPair(White,Cyan), - [SCREENS_OTH_BORDER] = ColorPair(White,Black), - [SCREENS_OTH_TEXT] = ColorPair(Cyan,Black), - [SCREENS_CUR_BORDER] = A_BOLD | ColorPair(White,Black), - [SCREENS_CUR_TEXT] = A_BOLD | ColorPair(Green,Black), + [PANEL_EDIT] = ColorPair(White, Cyan), + [SCREENS_OTH_BORDER] = ColorPair(White, Black), + [SCREENS_OTH_TEXT] = ColorPair(Cyan, Black), + [SCREENS_CUR_BORDER] = A_BOLD | ColorPair(White, Black), + [SCREENS_CUR_TEXT] = A_BOLD | ColorPair(Green, Black), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Green, Black), [PRESSURE_STALL_SIXTY] = ColorPair(Green, Black), [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(Green, Black), diff --git a/ColumnsPanel.c b/ColumnsPanel.c index 24826936..d53fff25 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -38,7 +38,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { HandlerResult result = IGNORED; int size = Panel_size(super); - switch(ch) { + switch (ch) { case 0x0a: case 0x0d: case KEY_ENTER: diff --git a/CommandLine.c b/CommandLine.c index 70b6d957..682e0542 100644 --- a/CommandLine.c +++ b/CommandLine.c @@ -146,7 +146,8 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar for (int j = 1; j < LAST_PROCESSFIELD; j++) { const char* name = Process_fields[j].name; const char* description = Process_fields[j].description; - if (name) printf("%19s %s\n", name, description); + if (name) + printf("%19s %s\n", name, description); } return STATUS_OK_EXIT; } @@ -166,8 +167,10 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar break; case 'd': if (sscanf(optarg, "%16d", &(flags->delay)) == 1) { - if (flags->delay < 1) flags->delay = 1; - if (flags->delay > 100) flags->delay = 100; + if (flags->delay < 1) + flags->delay = 1; + if (flags->delay > 100) + flags->delay = 100; } else { fprintf(stderr, "Error: invalid delay value \"%s\".\n", optarg); return STATUS_ERROR_EXIT; @@ -175,7 +178,7 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar break; case 'u': { - const char *username = optarg; + const char* username = optarg; if (!username && optind < argc && argv[optind] != NULL && (argv[optind][0] != '\0' && argv[optind][0] != '-')) { username = argv[optind++]; @@ -184,7 +187,7 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar if (!username) { flags->userId = geteuid(); } else if (!Action_setUserOnly(username, &(flags->userId))) { - for (const char *itr = username; *itr; ++itr) + for (const char* itr = username; *itr; ++itr) if (!isdigit((unsigned char)*itr)) { fprintf(stderr, "Error: invalid user \"%s\".\n", username); return STATUS_ERROR_EXIT; @@ -217,11 +220,11 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar flags->pidMatchList = Hashtable_new(8, false); } - while(pid) { - unsigned int num_pid = atoi(pid); - // deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here - Hashtable_put(flags->pidMatchList, num_pid, (void *) 1); - pid = strtok_r(NULL, ",", &saveptr); + while (pid) { + unsigned int num_pid = atoi(pid); + // deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here + Hashtable_put(flags->pidMatchList, num_pid, (void*) 1); + pid = strtok_r(NULL, ",", &saveptr); } free(argCopy); @@ -233,19 +236,19 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar break; } case 'H': { - const char *delay = optarg; + const char* delay = optarg; if (!delay && optind < argc && argv[optind] != NULL && (argv[optind][0] != '\0' && argv[optind][0] != '-')) { - delay = argv[optind++]; + delay = argv[optind++]; } if (delay) { - if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) { - if (flags->highlightDelaySecs < 1) - flags->highlightDelaySecs = 1; - } else { - fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay); - return STATUS_ERROR_EXIT; - } + if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) { + if (flags->highlightDelaySecs < 1) + flags->highlightDelaySecs = 1; + } else { + fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay); + return STATUS_ERROR_EXIT; + } } flags->highlightChanges = true; break; diff --git a/MetersPanel.c b/MetersPanel.c index c6926140..580e41bd 100644 --- a/MetersPanel.c +++ b/MetersPanel.c @@ -91,7 +91,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) { HandlerResult result = IGNORED; bool sideMove = false; - switch(ch) { + switch (ch) { case 0x0a: case 0x0d: case KEY_ENTER: @@ -110,7 +110,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) { break; Meter* meter = (Meter*) Vector_get(this->meters, selected); int mode = meter->mode + 1; - if (mode == LAST_METERMODE) mode = 1; + if (mode == LAST_METERMODE) + mode = 1; Meter_setMode(meter, mode); Panel_set(super, selected, (Object*) Meter_toListItem(meter, this->moving)); result = HANDLED; @@ -471,7 +471,8 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { len = strlen(buffer); for (int i = 0; i < size; i++) { const char* cur = ((ListItem*) Panel_get(this, i))->value; - while (*cur == ' ') cur++; + while (*cur == ' ') + cur++; if (strncasecmp(cur, buffer, len) == 0) { Panel_setSelected(this, i); return HANDLED; @@ -503,7 +503,7 @@ void Process_makeCommandStr(Process* this) { WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM); str = stpcpy(str, procComm); - if(!showMergedCommand) + if (!showMergedCommand) return; WRITE_SEPARATOR; diff --git a/ScreenManager.c b/ScreenManager.c index b2cbf8c8..55cacd20 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -115,7 +115,7 @@ void ScreenManager_resize(ScreenManager* this) { Panel_move(panel, lastX, y1_header); } -static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut, bool *force_redraw) { +static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut, bool* force_redraw) { ProcessList* pl = this->header->pl; Platform_gettime_realtime(&pl->realtime, &pl->realtimeMs); diff --git a/ScreensPanel.c b/ScreensPanel.c index 3d55546c..1fd4ae56 100644 --- a/ScreensPanel.c +++ b/ScreensPanel.c @@ -70,7 +70,7 @@ static HandlerResult ScreensPanel_eventHandlerRenaming(Panel* super, int ch) { Panel_setCursorToSelection(super); } } else { - switch(ch) { + switch (ch) { case 127: case KEY_BACKSPACE: { @@ -157,7 +157,7 @@ static void addNewScreen(Panel* super) { ScreensPanel* const this = (ScreensPanel*) super; const char* name = "New"; - ScreenSettings* ss = Settings_newScreen(this->settings, &(const ScreenDefaults){ .name = name, .columns = "PID Command", .sortKey = "PID" }); + ScreenSettings* ss = Settings_newScreen(this->settings, &(const ScreenDefaults) { .name = name, .columns = "PID Command", .sortKey = "PID" }); ScreenListItem* item = ScreenListItem_new(name, ss); int idx = Panel_getSelectedIndex(super); Panel_insert(super, idx + 1, (Object*) item); @@ -171,7 +171,7 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) { ScreenListItem* oldFocus = (ScreenListItem*) Panel_getSelected(super); bool shouldRebuildArray = false; HandlerResult result = IGNORED; - switch(ch) { + switch (ch) { case '\n': case '\r': case KEY_ENTER: @@ -478,7 +478,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini this->topologyAffinity = !!atoi(option[1]); #endif } else if (strncmp(option[0], "screen:", 7) == 0) { - screen = Settings_newScreen(this, &(const ScreenDefaults){ .name = option[0] + 7, .columns = option[1] }); + screen = Settings_newScreen(this, &(const ScreenDefaults) { .name = option[0] + 7, .columns = option[1] }); } else if (String_eq(option[0], ".sort_key")) { if (screen) screen->sortKey = toFieldIndex(this->dynamicColumns, option[1]); diff --git a/TraceScreen.c b/TraceScreen.c index 90400b43..2aa0781b 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -164,17 +164,17 @@ static void TraceScreen_updateTrace(InfoScreen* super) { static bool TraceScreen_onKey(InfoScreen* super, int ch) { TraceScreen* this = (TraceScreen*) super; - switch(ch) { + switch (ch) { case 'f': case KEY_F(8): this->follow = !(this->follow); if (this->follow) - Panel_setSelected(super->display, Panel_size(super->display)-1); + Panel_setSelected(super->display, Panel_size(super->display) - 1); return true; case 't': case KEY_F(9): this->tracing = !this->tracing; - FunctionBar_setLabel(super->display->defaultBar, KEY_F(9), this->tracing?"Stop Tracing ":"Resume Tracing "); + FunctionBar_setLabel(super->display->defaultBar, KEY_F(9), this->tracing ? "Stop Tracing " : "Resume Tracing "); InfoScreen_draw(this); return true; } @@ -104,9 +104,9 @@ inline bool String_contains_i(const char* s1, const char* s2, bool multi) { String_freeArray(needles); return true; } - } - String_freeArray(needles); - return false; + } + String_freeArray(needles); + return false; } else { return strcasestr(s1, s2) != NULL; } @@ -314,7 +314,7 @@ ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size return readfd_internal(fd, buffer, count); } -ssize_t full_write(int fd, const void *buf, size_t count) { +ssize_t full_write(int fd, const void* buf, size_t count) { ssize_t written = 0; while (count > 0) { @@ -73,6 +73,6 @@ char* xStrndup(const char* str, size_t len) ATTR_NONNULL ATTR_MALLOC; ssize_t xReadfile(const char* pathname, void* buffer, size_t count); ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size_t count); -ssize_t full_write(int fd, const void *buf, size_t count); +ssize_t full_write(int fd, const void* buf, size_t count); #endif diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index d0204ddc..6027c25b 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -282,7 +282,7 @@ static char* DarwinProcess_getDevname(dev_t dev) { return NULL; } char buf[sizeof("/dev/") + MAXNAMLEN]; - char *name = devname_r(dev, S_IFCHR, buf, MAXNAMLEN); + char* name = devname_r(dev, S_IFCHR, buf, MAXNAMLEN); if (name) { return xStrdup(name); } diff --git a/darwin/Platform.h b/darwin/Platform.h index 4f8e7c9d..3fd46add 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -100,7 +100,9 @@ static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) void Platform_gettime_monotonic(uint64_t* msec); -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -110,12 +112,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/darwin/PlatformHelpers.c b/darwin/PlatformHelpers.c index bde90685..1b9a246d 100644 --- a/darwin/PlatformHelpers.c +++ b/darwin/PlatformHelpers.c @@ -58,7 +58,7 @@ bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upp && Platform_CompareKernelVersion(upperBound) < 0; } -void Platform_getCPUBrandString(char *cpuBrandString, size_t cpuBrandStringSize) { +void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize) { if (sysctlbyname("machdep.cpu.brand_string", cpuBrandString, &cpuBrandStringSize, NULL, 0) == -1) { fprintf(stderr, "WARN: Unable to determine the CPU brand string.\n" @@ -74,7 +74,8 @@ bool Platform_isRunningTranslated() { size_t size = sizeof(ret); errno = 0; if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) { - if (errno == ENOENT) return false; + if (errno == ENOENT) + return false; fprintf(stderr, "WARN: Could not determine if this process was running in a translation environment like Rosetta 2.\n" diff --git a/darwin/PlatformHelpers.h b/darwin/PlatformHelpers.h index 07f3fe23..45aea1a7 100644 --- a/darwin/PlatformHelpers.h +++ b/darwin/PlatformHelpers.h @@ -31,7 +31,7 @@ bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upp double Platform_calculateNanosecondsPerMachTick(void); -void Platform_getCPUBrandString(char *cpuBrandString, size_t cpuBrandStringSize); +void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize); bool Platform_isRunningTranslated(void); diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index e60ad144..f46d6cec 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -527,7 +527,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { else proc->priority = -kproc->kp_lwp.kl_tdprio; - switch(kproc->kp_lwp.kl_rtprio.type) { + switch (kproc->kp_lwp.kl_rtprio.type) { case RTP_PRIO_REALTIME: proc->nice = PRIO_MIN - 1 - RTP_PRIO_MAX + kproc->kp_lwp.kl_rtprio.prio; break; diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index ec140ad0..3de87718 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -93,7 +93,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -103,12 +105,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/freebsd/Platform.h b/freebsd/Platform.h index c0292d9a..555ab902 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -93,7 +93,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -103,12 +105,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/linux/CGroupUtils.c b/linux/CGroupUtils.c index 22cce91b..c11c4608 100644 --- a/linux/CGroupUtils.c +++ b/linux/CGroupUtils.c @@ -11,7 +11,7 @@ in the source distribution for its full text. typedef struct StrBuf_state { - char *buf; + char* buf; size_t size; size_t pos; } StrBuf_state; @@ -60,7 +60,7 @@ static bool Label_checkSuffix(const char* labelStart, size_t labelLen, const cha return labelLen > strlen(expected) && String_startsWith(labelStart + labelLen - strlen(expected), expected); } -static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrBuf_putc_t w) { +static bool CGroup_filterName_internal(const char* cgroup, StrBuf_state* s, StrBuf_putc_t w) { const char* str_slice_suffix = ".slice"; const char* str_system_slice = "system.slice"; const char* str_user_slice = "user.slice"; @@ -237,7 +237,7 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB if (String_startsWith(cgroup, "user@")) { cgroup = nextSlash; - while(*cgroup == '/') + while (*cgroup == '/') cgroup++; continue; @@ -275,7 +275,7 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB cgroup += strlen(str_nspawn_payload_label); continue; - } else if(Label_checkPrefix(labelStart, scopeNameLen, str_snap_scope_prefix)) { + } else if (Label_checkPrefix(labelStart, scopeNameLen, str_snap_scope_prefix)) { const char* nextDot = strchrnul(labelStart + strlen(str_snap_scope_prefix), '.'); if (!StrBuf_putsz(s, w, "!snap:")) @@ -316,7 +316,7 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB return true; } -char* CGroup_filterName(const char *cgroup) { +char* CGroup_filterName(const char* cgroup) { StrBuf_state s = { .buf = NULL, .size = 0, diff --git a/linux/CGroupUtils.h b/linux/CGroupUtils.h index db2df7f4..ff134374 100644 --- a/linux/CGroupUtils.h +++ b/linux/CGroupUtils.h @@ -11,6 +11,6 @@ in the source distribution for its full text. #include <stddef.h> -char* CGroup_filterName(const char *cgroup); +char* CGroup_filterName(const char* cgroup); #endif /* HEADER_CGroupUtils */ diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index b6b88405..eca9459b 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -182,7 +182,7 @@ static unsigned int scanAvailableCPUsFromCPUinfo(LinuxProcessList* this) { if (String_startsWith(buffer, "processor")) availableCPUs++; - } + } fclose(file); @@ -220,7 +220,7 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super) { if (!String_startsWith(entry->d_name, "cpu")) continue; - char *endp; + char* endp; unsigned long int id = strtoul(entry->d_name + 3, &endp, 10); if (id == ULONG_MAX || endp == entry->d_name + 3 || *endp != '\0') continue; @@ -672,7 +672,7 @@ static void LinuxProcessList_readMaps(LinuxProcess* process, openat_arg_t procFd if (' ' != *readptr++) continue; - while(*readptr > ' ') + while (*readptr > ' ') readptr++; // Skip parsing this hex value if (' ' != *readptr++) continue; @@ -764,8 +764,8 @@ static bool LinuxProcessList_readStatmFile(LinuxProcess* process, openat_arg_t p return r == 7; } -static bool LinuxProcessList_checkPidNamespace(Process *process, openat_arg_t procFd) { - FILE *statusfile = fopenat(procFd, "status", "r"); +static bool LinuxProcessList_checkPidNamespace(Process* process, openat_arg_t procFd) { + FILE* statusfile = fopenat(procFd, "status", "r"); if (!statusfile) return false; @@ -777,7 +777,7 @@ static bool LinuxProcessList_checkPidNamespace(Process *process, openat_arg_t pr if (!String_startsWith(buffer, "NSpid:")) continue; - char *ptr = buffer; + char* ptr = buffer; int pid_ns_count = 0; while (*ptr && *ptr != '\n' && !isdigit(*ptr)) ++ptr; @@ -889,7 +889,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, openat_arg_t char* value_end = name_value_sep; - while(*value_end > 32) { + while (*value_end > 32) { value_end++; } @@ -899,7 +899,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, openat_arg_t *value_end = '\0'; - switch(field) { + switch (field) { case 1: foundEnvID = true; if (!String_eq(name_value_sep, process->ctid ? process->ctid : "")) @@ -929,7 +929,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, openat_arg_t #endif -static bool isContainerOrVMSlice(char *cgroup) { +static bool isContainerOrVMSlice(char* cgroup) { if (String_startsWith(cgroup, "/user") || String_startsWith(cgroup, "/system")) return false; @@ -986,7 +986,7 @@ static void LinuxProcessList_readCGroupFile(LinuxProcess* process, openat_arg_t free_and_xStrdup(&process->cgroup, output); if (!changed) { - if(process->cgroup_short) { + if (process->cgroup_short) { Process_updateFieldWidth(CCGROUP, strlen(process->cgroup_short)); } else { //CCGROUP is alias to normal CGROUP if shortening fails diff --git a/linux/Platform.c b/linux/Platform.c index e442e14b..f9cd4d50 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -496,7 +496,7 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { char buffer[1024]; FileLocks_LockData** data_ref = &pdata->locks; - while(fgets(buffer, sizeof(buffer), f)) { + while (fgets(buffer, sizeof(buffer), f)) { if (!strchr(buffer, '\n')) continue; diff --git a/linux/Platform.h b/linux/Platform.h index e6fa1610..c8849684 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -114,7 +114,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -124,12 +126,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/netbsd/Platform.c b/netbsd/Platform.c index cf6079db..5b4fd395 100644 --- a/netbsd/Platform.c +++ b/netbsd/Platform.c @@ -351,7 +351,7 @@ FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { bool Platform_getDiskIO(DiskIOData* data) { const int mib[] = { CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl) }; - struct io_sysctl *iostats = NULL; + struct io_sysctl* iostats = NULL; size_t size = 0; for (int retry = 3; retry > 0; retry--) { diff --git a/netbsd/Platform.h b/netbsd/Platform.h index 3ad51e28..f2e5823d 100644 --- a/netbsd/Platform.h +++ b/netbsd/Platform.h @@ -97,7 +97,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -107,12 +109,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/openbsd/Platform.h b/openbsd/Platform.h index e3d61163..19818ff9 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -91,7 +91,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -101,12 +103,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/pcp/Platform.c b/pcp/Platform.c index bec5cad9..2987c8e9 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -256,7 +256,7 @@ static const char* Platform_metricNames[] = { * libpcp version avoids by using a protocol extension. In time, * perhaps in a few years, we could remove this back-compat code. */ -int pmLookupDescs(int numpmid, pmID *pmids, pmDesc *descs) { +int pmLookupDescs(int numpmid, pmID* pmids, pmDesc* descs) { int count = 0; for (int i = 0; i < numpmid; i++) { diff --git a/solaris/Platform.h b/solaris/Platform.h index 1b3dc9f5..136db197 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -132,7 +132,9 @@ IGNORE_WCASTQUAL_BEGIN IGNORE_WCASTQUAL_END } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -142,12 +144,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif diff --git a/unsupported/Platform.h b/unsupported/Platform.h index 5c874d48..69191e35 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -80,7 +80,9 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) { Generic_gettime_monotonic(msec); } -static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } +static inline Hashtable* Platform_dynamicMeters(void) { + return NULL; +} static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } @@ -90,12 +92,18 @@ static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } -static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } +static inline Hashtable* Platform_dynamicColumns(void) { + return NULL; +} static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } -static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } +static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { + return NULL; +} -static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } +static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { + return false; +} #endif |