mirror of https://github.com/xzeldon/htop.git
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:
parent
5228f5d47a
commit
500fb283e9
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Affinity.c
|
htop - Affinity.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +80,8 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
||||||
return affinity;
|
return affinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Affinity_set(Process* proc, Affinity* this) {
|
bool Affinity_set(Process* proc, Arg arg) {
|
||||||
|
Affinity *this = arg.v;
|
||||||
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
||||||
for (int i = 0; i < this->used; i++) {
|
for (int i = 0; i < this->used; i++) {
|
||||||
hwloc_bitmap_set(cpuset, this->cpus[i]);
|
hwloc_bitmap_set(cpuset, this->cpus[i]);
|
||||||
|
@ -103,7 +105,8 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
||||||
return affinity;
|
return affinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Affinity_set(Process* proc, Affinity* this) {
|
bool Affinity_set(Process* proc, Arg arg) {
|
||||||
|
Affinity *this = arg.v;
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
CPU_ZERO(&cpuset);
|
CPU_ZERO(&cpuset);
|
||||||
for (int i = 0; i < this->used; i++) {
|
for (int i = 0; i < this->used; i++) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Affinity.h
|
htop - Affinity.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -39,13 +40,13 @@ extern void Affinity_add(Affinity* this, int id);
|
||||||
|
|
||||||
extern Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
extern Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
||||||
|
|
||||||
extern bool Affinity_set(Process* proc, Affinity* this);
|
extern bool Affinity_set(Process* proc, Arg arg);
|
||||||
|
|
||||||
#elif HAVE_LINUX_AFFINITY
|
#elif HAVE_LINUX_AFFINITY
|
||||||
|
|
||||||
extern Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
extern Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
||||||
|
|
||||||
extern bool Affinity_set(Process* proc, Affinity* this);
|
extern bool Affinity_set(Process* proc, Arg arg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
htop - ColumnsPanel.c
|
htop - ColumnsPanel.c
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -25,11 +26,6 @@ typedef struct MainPanel_ {
|
||||||
pid_t pidSearch;
|
pid_t pidSearch;
|
||||||
} MainPanel;
|
} MainPanel;
|
||||||
|
|
||||||
typedef union {
|
|
||||||
int i;
|
|
||||||
void* v;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
||||||
|
|
||||||
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
/*
|
/*
|
||||||
htop - ColumnsPanel.h
|
htop - ColumnsPanel.h
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -21,11 +22,6 @@ typedef struct MainPanel_ {
|
||||||
pid_t pidSearch;
|
pid_t pidSearch;
|
||||||
} MainPanel;
|
} MainPanel;
|
||||||
|
|
||||||
typedef union {
|
|
||||||
int i;
|
|
||||||
void* v;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
||||||
|
|
||||||
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
||||||
|
|
6
Object.c
6
Object.c
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Object.c
|
htop - Object.c
|
||||||
(C) 2004-2012 Hisham H. Muhammad
|
(C) 2004-2012 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +41,11 @@ struct Object_ {
|
||||||
ObjectClass* klass;
|
ObjectClass* klass;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
int i;
|
||||||
|
void* v;
|
||||||
|
} Arg;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
ObjectClass Object_class = {
|
ObjectClass Object_class = {
|
||||||
|
|
6
Object.h
6
Object.h
|
@ -5,6 +5,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Object.h
|
htop - Object.h
|
||||||
(C) 2004-2012 Hisham H. Muhammad
|
(C) 2004-2012 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +42,11 @@ struct Object_ {
|
||||||
ObjectClass* klass;
|
ObjectClass* klass;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
int i;
|
||||||
|
void* v;
|
||||||
|
} Arg;
|
||||||
|
|
||||||
|
|
||||||
extern ObjectClass Object_class;
|
extern ObjectClass Object_class;
|
||||||
|
|
||||||
|
|
10
Process.c
10
Process.c
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Process.c
|
htop - Process.c
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -561,14 +562,15 @@ bool Process_setPriority(Process* this, int priority) {
|
||||||
return (err == 0);
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process_changePriorityBy(Process* this, int delta) {
|
bool Process_changePriorityBy(Process* this, Arg delta) {
|
||||||
return Process_setPriority(this, this->nice + 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();
|
CRT_dropPrivileges();
|
||||||
kill(this->pid, (int) sgn);
|
bool ok = (kill(this->pid, sgn.i) == 0);
|
||||||
CRT_restorePrivileges();
|
CRT_restorePrivileges();
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
long Process_pidCompare(const void* v1, const void* v2) {
|
long Process_pidCompare(const void* v1, const void* v2) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
/*
|
/*
|
||||||
htop - Process.h
|
htop - Process.h
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -199,9 +200,9 @@ extern void Process_toggleTag(Process* this);
|
||||||
|
|
||||||
extern bool Process_setPriority(Process* this, int priority);
|
extern bool Process_setPriority(Process* this, int priority);
|
||||||
|
|
||||||
extern bool Process_changePriorityBy(Process* this, int delta);
|
extern bool Process_changePriorityBy(Process* this, Arg delta);
|
||||||
|
|
||||||
extern void Process_sendSignal(Process* this, int sgn);
|
extern bool Process_sendSignal(Process* this, Arg sgn);
|
||||||
|
|
||||||
extern long Process_pidCompare(const void* v1, const void* v2);
|
extern long Process_pidCompare(const void* v1, const void* v2);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
htop - LinuxProcess.c
|
htop - LinuxProcess.c
|
||||||
(C) 2014 Hisham H. Muhammad
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -314,12 +315,12 @@ IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) {
|
||||||
return ioprio;
|
return ioprio;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) {
|
bool LinuxProcess_setIOPriority(LinuxProcess* this, Arg ioprio) {
|
||||||
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
|
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
|
||||||
#ifdef SYS_ioprio_set
|
#ifdef SYS_ioprio_set
|
||||||
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio);
|
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio.i);
|
||||||
#endif
|
#endif
|
||||||
return (LinuxProcess_updateIOPriority(this) == ioprio);
|
return (LinuxProcess_updateIOPriority(this) == ioprio.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
/*
|
/*
|
||||||
htop - LinuxProcess.h
|
htop - LinuxProcess.h
|
||||||
(C) 2014 Hisham H. Muhammad
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -176,7 +177,7 @@ extern io_priority;
|
||||||
|
|
||||||
extern IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
|
extern IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
|
||||||
|
|
||||||
extern bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio);
|
extern bool LinuxProcess_setIOPriority(LinuxProcess* this, Arg ioprio);
|
||||||
|
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
extern void LinuxProcess_printDelay(float delay_percent, char* buffer, int n);
|
extern void LinuxProcess_printDelay(float delay_percent, char* buffer, int n);
|
||||||
|
|
Loading…
Reference in New Issue