diff --git a/Action.c b/Action.c index 50ab0bb9b9fc7fa8c2e1899344bdf52eedb1b7ee..1cb59aa038c8ee7649ef027e2c75500249795d9f 100644 --- a/Action.c +++ b/Action.c @@ -115,7 +115,7 @@ static void Action_runSetup(Settings* settings, const Header* header, ProcessLis static bool changePriority(MainPanel* panel, int delta) { bool anyTagged; - bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, delta, &anyTagged); + bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, (Arg){ .i = delta }, &anyTagged); if (!ok) beep(); return anyTagged; @@ -285,7 +285,7 @@ static Htop_Reaction actionSetAffinity(State* st) { void* set = Action_pickFromVector(st, affinityPanel, 15); if (set) { Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl); - bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (size_t) affinity, NULL); + bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL); if (!ok) beep(); Affinity_delete(affinity); } @@ -302,7 +302,7 @@ static Htop_Reaction actionKill(State* st) { Panel_setHeader(st->panel, "Sending..."); Panel_draw(st->panel, true); refresh(); - MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (size_t) sgn->key, NULL); + MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (Arg){ .i = sgn->key }, NULL); napms(500); } } diff --git a/InfoScreen.c b/InfoScreen.c index dd5095c7f61a8814b2ee791170ce58d0b0d88e3e..fab8daeaf092a5f7eb0294c55329953c05f0b718 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -115,8 +115,9 @@ void InfoScreen_run(InfoScreen* this) { Panel_draw(panel, true); - if (this->inc->active) - move(LINES-1, CRT_cursorX); + if (this->inc->active) { + (void) move(LINES-1, CRT_cursorX); + } set_escdelay(25); int ch = getch(); diff --git a/MainPanel.c b/MainPanel.c index b5a7e30578ec089e6f7a79bd084be86e86e43fec..25023367f7e80cb59be538430afea31cbb1e33e2 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -25,7 +25,12 @@ typedef struct MainPanel_ { pid_t pidSearch; } MainPanel; -typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t); +typedef union { + int i; + void* v; +} Arg; + +typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg); #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) @@ -148,7 +153,7 @@ const char* MainPanel_getValue(MainPanel* this, int i) { return ""; } -bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, size_t arg, bool* wasAnyTagged) { +bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged) { Panel* super = (Panel*) this; bool ok = true; bool anyTagged = false; diff --git a/MainPanel.h b/MainPanel.h index f4671f330ad85570dedbac1a12e2ac36f7b9949b..884965977ad4b818e729f0adc1f2c872b960cab0 100644 --- a/MainPanel.h +++ b/MainPanel.h @@ -21,7 +21,12 @@ typedef struct MainPanel_ { pid_t pidSearch; } MainPanel; -typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t); +typedef union { + int i; + void* v; +} Arg; + +typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg); #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) @@ -34,7 +39,7 @@ int MainPanel_selectedPid(MainPanel* this); const char* MainPanel_getValue(MainPanel* this, int i); -bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, size_t arg, bool* wasAnyTagged); +bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged); extern PanelClass MainPanel_class; diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index a772bbac4f3710eb39405794e7cf695aa235161b..f18511bb95e01e94c39dee5fe2baed4baa64e09e 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -130,7 +130,7 @@ void OpenFilesScreen_scan(InfoScreen* this) { char** data = fdata->data.data; int lenN = data['n'] ? strlen(data['n']) : 0; int sizeEntry = 5 + 7 + 10 + 10 + 10 + lenN + 5 /*spaces*/ + 1 /*null*/; - char* entry = xMalloc(sizeEntry); + char entry[sizeEntry]; xSnprintf(entry, sizeEntry, "%5.5s %7.7s %10.10s %10.10s %10.10s %s", data['f'] ? data['f'] : "", data['t'] ? data['t'] : "", diff --git a/Process.c b/Process.c index 1836080257f27edaf2ce3f105f4735d4bd728766..2ff778dff1e5c530478ac68ac5e1061805f051ad 100644 --- a/Process.c +++ b/Process.c @@ -536,11 +536,11 @@ bool Process_setPriority(Process* this, int priority) { return (err == 0); } -bool Process_changePriorityBy(Process* this, size_t delta) { +bool Process_changePriorityBy(Process* this, int delta) { return Process_setPriority(this, this->nice + delta); } -void Process_sendSignal(Process* this, size_t sgn) { +void Process_sendSignal(Process* this, int sgn) { CRT_dropPrivileges(); kill(this->pid, (int) sgn); CRT_restorePrivileges(); diff --git a/Process.h b/Process.h index 5179bb6f51787d3bd44cab971718509cced85ed5..6c41edc2fdd8cf5400ce6a78980776ca0a6204cb 100644 --- a/Process.h +++ b/Process.h @@ -190,9 +190,9 @@ void Process_toggleTag(Process* this); bool Process_setPriority(Process* this, int priority); -bool Process_changePriorityBy(Process* this, size_t delta); +bool Process_changePriorityBy(Process* this, int delta); -void Process_sendSignal(Process* this, size_t sgn); +void Process_sendSignal(Process* this, int sgn); long Process_pidCompare(const void* v1, const void* v2); diff --git a/TraceScreen.c b/TraceScreen.c index abef7120f7ac1eba941a0b7b629eb933509731b0..845ceaab992c16c3d0088b07c6f7d200eb880bf3 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -108,7 +108,8 @@ bool TraceScreen_forkTracer(TraceScreen* this) { (void) written; exit(1); } - fcntl(this->fdpair[0], F_SETFL, O_NONBLOCK); + int ok = fcntl(this->fdpair[0], F_SETFL, O_NONBLOCK); + if (ok == -1) return false; this->strace = fdopen(this->fdpair[0], "r"); this->fd_strace = fileno(this->strace); return true; diff --git a/linux/Platform.c b/linux/Platform.c index 025abff69b0cbf6d121e07827bffe5721345d2fc..ab90ca74bd209730b8baa5edf82c2f8a04bcc8fc 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -96,7 +96,7 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) { void* set = Action_pickFromVector(st, ioprioPanel, 21); if (set) { IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel); - bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (size_t) ioprio, NULL); + bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (Arg){ .i = ioprio }, NULL); if (!ok) beep(); }