diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-12-15 19:44:48 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-12-19 21:13:32 +0100 |
commit | 89473cc9ae950bbb5e291d1f186d372f66f66394 (patch) | |
tree | d1e21dbd0df28c00c467695711c8dde884e746a1 /freebsd | |
parent | d872e363081a892d65dede6a90721d3a2e8b0ee6 (diff) |
Rework enum ProcessField
Use only one enum instead of a global and a platform specific one.
Drop Platform_numberOfFields global variable.
Set known size of Process_fields array
Diffstat (limited to 'freebsd')
-rw-r--r-- | freebsd/FreeBSDProcess.c | 7 | ||||
-rw-r--r-- | freebsd/FreeBSDProcess.h | 9 | ||||
-rw-r--r-- | freebsd/Platform.c | 2 | ||||
-rw-r--r-- | freebsd/Platform.h | 4 | ||||
-rw-r--r-- | freebsd/ProcessField.h | 17 |
5 files changed, 21 insertions, 18 deletions
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c index a7c079c0..ff4b2df1 100644 --- a/freebsd/FreeBSDProcess.c +++ b/freebsd/FreeBSDProcess.c @@ -18,7 +18,7 @@ in the source distribution for its full text. const char* const nodevStr = "nodev"; -ProcessFieldData Process_fields[] = { +ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, }, [COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, }, @@ -47,7 +47,6 @@ ProcessFieldData Process_fields[] = { [TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, }, [JID] = { .name = "JID", .title = " JID ", .description = "Jail prison ID", .flags = 0, }, [JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, }, - [LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, }, }; ProcessPidColumn Process_pidColumns[] = { @@ -80,7 +79,7 @@ static void FreeBSDProcess_writeField(const Process* this, RichString* str, Proc char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; int n = sizeof(buffer) - 1; - switch ((int) field) { + switch (field) { // add FreeBSD-specific fields here case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break; case JAIL: { @@ -112,7 +111,7 @@ static long FreeBSDProcess_compareByKey(const Process* v1, const Process* v2, Pr const FreeBSDProcess* p1 = (const FreeBSDProcess*)v1; const FreeBSDProcess* p2 = (const FreeBSDProcess*)v2; - switch ((int) key) { + switch (key) { // add FreeBSD-specific fields here case JID: return SPACESHIP_NUMBER(p1->jid, p2->jid); diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h index 89119764..96b70ec4 100644 --- a/freebsd/FreeBSDProcess.h +++ b/freebsd/FreeBSDProcess.h @@ -18,13 +18,6 @@ in the source distribution for its full text. extern const char* const nodevStr; -typedef enum FreeBSDProcessFields_ { - // Add platform-specific fields here, with ids >= 100 - JID = 100, - JAIL = 101, - LAST_PROCESSFIELD = 102, -} FreeBSDProcessField; - typedef struct FreeBSDProcess_ { Process super; int kernel; @@ -43,7 +36,7 @@ static inline bool Process_isUserlandThread(const Process* this) { extern const ProcessClass FreeBSDProcess_class; -extern ProcessFieldData Process_fields[]; +extern ProcessFieldData Process_fields[LAST_PROCESSFIELD]; extern ProcessPidColumn Process_pidColumns[]; diff --git a/freebsd/Platform.c b/freebsd/Platform.c index bc77cf46..3cec913d 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -49,8 +49,6 @@ in the source distribution for its full text. ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; -int Platform_numberOfFields = LAST_PROCESSFIELD; - const SignalItem Platform_signals[] = { { .name = " 0 Cancel", .number = 0 }, { .name = " 1 SIGHUP", .number = 1 }, diff --git a/freebsd/Platform.h b/freebsd/Platform.h index 5b3b0195..793746e7 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -19,12 +19,8 @@ in the source distribution for its full text. #include "SignalsPanel.h" -extern ProcessFieldData Process_fields[]; - extern ProcessField Platform_defaultFields[]; -extern int Platform_numberOfFields; - extern const SignalItem Platform_signals[]; extern const unsigned int Platform_numberOfSignals; diff --git a/freebsd/ProcessField.h b/freebsd/ProcessField.h new file mode 100644 index 00000000..cc892826 --- /dev/null +++ b/freebsd/ProcessField.h @@ -0,0 +1,17 @@ +#ifndef HEADER_FreeBSDProcessField +#define HEADER_FreeBSDProcessField +/* +htop - freebsd/ProcessField.h +(C) 2020 htop dev team +Released under the GNU GPLv2, see the COPYING file +in the source distribution for its full text. +*/ + + +#define PLATFORM_PROCESS_FIELDS \ + JID = 100, \ + JAIL = 101, \ + // End of list + + +#endif /* HEADER_FreeBSDProcessField */ |