summaryrefslogtreecommitdiffstats
path: root/dragonflybsd
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-12-15 19:44:48 +0100
committercgzones <cgzones@googlemail.com>2020-12-19 21:13:32 +0100
commit89473cc9ae950bbb5e291d1f186d372f66f66394 (patch)
treed1e21dbd0df28c00c467695711c8dde884e746a1 /dragonflybsd
parentd872e363081a892d65dede6a90721d3a2e8b0ee6 (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 'dragonflybsd')
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.c7
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.h9
-rw-r--r--dragonflybsd/Platform.c2
-rw-r--r--dragonflybsd/Platform.h3
-rw-r--r--dragonflybsd/ProcessField.h17
5 files changed, 21 insertions, 17 deletions
diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c
index 32ca12fd..31211725 100644
--- a/dragonflybsd/DragonFlyBSDProcess.c
+++ b/dragonflybsd/DragonFlyBSDProcess.c
@@ -29,7 +29,7 @@ const ProcessClass DragonFlyBSDProcess_class = {
.compareByKey = DragonFlyBSDProcess_compareByKey
};
-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, },
@@ -57,7 +57,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[] = {
@@ -90,7 +89,7 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
- switch ((int) field) {
+ switch (field) {
// add Platform-specific fields here
case PID: xSnprintf(buffer, n, Process_pidFormat, (fp->kernel ? -1 : this->pid)); break;
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
@@ -113,7 +112,7 @@ long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, Proc
const DragonFlyBSDProcess* p1 = (const DragonFlyBSDProcess*)v1;
const DragonFlyBSDProcess* p2 = (const DragonFlyBSDProcess*)v2;
- switch ((int) key) {
+ switch (key) {
// add Platform-specific fields here
case JID:
return SPACESHIP_NUMBER(p1->jid, p2->jid);
diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h
index 0bb173ec..7d5d3e52 100644
--- a/dragonflybsd/DragonFlyBSDProcess.h
+++ b/dragonflybsd/DragonFlyBSDProcess.h
@@ -8,13 +8,6 @@ Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-typedef enum DragonFlyBSDProcessFields {
- // Add platform-specific fields here, with ids >= 100
- JID = 100,
- JAIL = 101,
- LAST_PROCESSFIELD = 102,
-} DragonFlyBSDProcessField;
-
typedef struct DragonFlyBSDProcess_ {
Process super;
int kernel;
@@ -29,7 +22,7 @@ typedef struct DragonFlyBSDProcess_ {
extern const ProcessClass DragonFlyBSDProcess_class;
-extern ProcessFieldData Process_fields[];
+extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
extern ProcessPidColumn Process_pidColumns[];
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index 40a73487..6f2d7bdc 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -33,8 +33,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/dragonflybsd/Platform.h b/dragonflybsd/Platform.h
index 5456539e..51d4c2cf 100644
--- a/dragonflybsd/Platform.h
+++ b/dragonflybsd/Platform.h
@@ -17,12 +17,9 @@ in the source distribution for its full text.
#include "ProcessLocksScreen.h"
#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/dragonflybsd/ProcessField.h b/dragonflybsd/ProcessField.h
new file mode 100644
index 00000000..a32e3d3b
--- /dev/null
+++ b/dragonflybsd/ProcessField.h
@@ -0,0 +1,17 @@
+#ifndef HEADER_DragonFlyBSDProcessField
+#define HEADER_DragonFlyBSDProcessField
+/*
+htop - dragonflybsd/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_DragonFlyBSDProcessField */

© 2014-2024 Faster IT GmbH | imprint | privacy policy