Resolve compiler warnings and errors relating to the Arg union

Promote the Arg union to a core data type in Object.c such
that it is visible everywhere (many source files need it),
and correct declarations of several functions that use it.

The Process_sendSignal function is also corrected to have
the expected return type (bool, not void) - an error being
masked by ignoring this not-quite-harmless warning.  I've
also added error checking to the kill(2) call here, which
was previously overlooked / missing (?).
This commit is contained in:
Nathan Scott
2020-08-20 09:35:24 +10:00
parent 5228f5d47a
commit 500fb283e9
10 changed files with 37 additions and 24 deletions

View File

@ -1,6 +1,7 @@
/*
htop - Process.c
(C) 2004-2015 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
@ -561,14 +562,15 @@ bool Process_setPriority(Process* this, int priority) {
return (err == 0);
}
bool Process_changePriorityBy(Process* this, int delta) {
return Process_setPriority(this, this->nice + delta);
bool Process_changePriorityBy(Process* this, Arg delta) {
return Process_setPriority(this, this->nice + delta.i);
}
void Process_sendSignal(Process* this, int sgn) {
bool Process_sendSignal(Process* this, Arg sgn) {
CRT_dropPrivileges();
kill(this->pid, (int) sgn);
bool ok = (kill(this->pid, sgn.i) == 0);
CRT_restorePrivileges();
return ok;
}
long Process_pidCompare(const void* v1, const void* v2) {