From 9a86577cf29e8cabc1298cda2250d092d590aa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 20 Dec 2020 18:32:04 +0100 Subject: DragonFlyBSD update - move some functions to file scope - drop unused global variable --- dragonflybsd/DragonFlyBSDProcess.c | 28 ++++++++++++++-------------- dragonflybsd/DragonFlyBSDProcess.h | 4 ---- dragonflybsd/DragonFlyBSDProcessList.c | 8 ++++---- dragonflybsd/DragonFlyBSDProcessList.h | 6 ------ 4 files changed, 18 insertions(+), 28 deletions(-) (limited to 'dragonflybsd') diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c index 20fe5e78..35594c78 100644 --- a/dragonflybsd/DragonFlyBSDProcess.c +++ b/dragonflybsd/DragonFlyBSDProcess.c @@ -18,17 +18,6 @@ in the source distribution for its full text. #include -const ProcessClass DragonFlyBSDProcess_class = { - .super = { - .extends = Class(Process), - .display = Process_display, - .delete = Process_delete, - .compare = Process_compare - }, - .writeField = DragonFlyBSDProcess_writeField, - .compareByKey = DragonFlyBSDProcess_compareByKey -}; - const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, }, @@ -73,11 +62,11 @@ void Process_delete(Object* cast) { free(this); } -void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) { +static void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) { const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this; char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; - int n = sizeof(buffer) - 1; + size_t n = sizeof(buffer) - 1; switch (field) { // add Platform-specific fields here case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, (fp->kernel ? -1 : this->pid)); break; @@ -97,7 +86,7 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces RichString_appendWide(str, attr, buffer); } -long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) { +static long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) { const DragonFlyBSDProcess* p1 = (const DragonFlyBSDProcess*)v1; const DragonFlyBSDProcess* p2 = (const DragonFlyBSDProcess*)v2; @@ -121,3 +110,14 @@ bool Process_isThread(const Process* this) { return (Process_isUserlandThread(this)); } } + +const ProcessClass DragonFlyBSDProcess_class = { + .super = { + .extends = Class(Process), + .display = Process_display, + .delete = Process_delete, + .compare = Process_compare + }, + .writeField = DragonFlyBSDProcess_writeField, + .compareByKey = DragonFlyBSDProcess_compareByKey +}; diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h index 1527417b..dc40a993 100644 --- a/dragonflybsd/DragonFlyBSDProcess.h +++ b/dragonflybsd/DragonFlyBSDProcess.h @@ -28,10 +28,6 @@ Process* DragonFlyBSDProcess_new(const Settings* settings); void Process_delete(Object* cast); -void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field); - -long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key); - bool Process_isThread(const Process* this); #endif diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 07fceefa..d935a72c 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -262,7 +262,7 @@ static inline void DragonFlyBSDProcessList_scanMemoryInfo(ProcessList* pl) { pl->usedSwap *= pageSizeKb; } -char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) { +static char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, const struct kinfo_proc* kproc, int* basenameEnd) { char** argv = kvm_getargv(kd, kproc, 0); if (!argv) { return xStrdup(kproc->kp_comm); @@ -343,7 +343,7 @@ retry: free(jls); } -char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) { +static char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) { char* hostname; char* jname; @@ -373,10 +373,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { int count = 0; // TODO Kernel Threads seem to be skipped, need to figure out the correct flag - struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count); + const struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count); for (int i = 0; i < count; i++) { - struct kinfo_proc* kproc = &kprocs[i]; + const struct kinfo_proc* kproc = &kprocs[i]; bool preExisting = false; bool ATTR_UNUSED isIdleProcess = false; diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h index f2c7ce70..80fb9f38 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.h +++ b/dragonflybsd/DragonFlyBSDProcessList.h @@ -17,8 +17,6 @@ in the source distribution for its full text. #include "Hashtable.h" #include "DragonFlyBSDProcess.h" -#define JAIL_ERRMSGLEN 1024 -extern char jail_errmsg[JAIL_ERRMSGLEN]; typedef struct CPUData_ { double userPercent; @@ -53,10 +51,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui void ProcessList_delete(ProcessList* this); -char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd); - -char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid); - void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); #endif -- cgit v1.2.3