From 41eea8a355d9f8935c2bcb25b4da83cf628f357b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 7 Oct 2020 19:02:15 +0200 Subject: [PATCH] Mark process argument of Process_isThread const --- InfoScreen.c | 2 +- InfoScreen.h | 4 ++-- Process.h | 2 +- darwin/DarwinProcess.c | 2 +- darwin/DarwinProcess.h | 2 +- dragonflybsd/DragonFlyBSDProcess.c | 4 ++-- dragonflybsd/DragonFlyBSDProcess.h | 2 +- freebsd/FreeBSDProcess.c | 4 ++-- freebsd/FreeBSDProcess.h | 2 +- linux/LinuxProcess.c | 2 +- linux/LinuxProcess.h | 4 ++-- openbsd/OpenBSDProcess.c | 2 +- openbsd/OpenBSDProcess.h | 2 +- solaris/SolarisProcess.c | 4 ++-- solaris/SolarisProcess.h | 2 +- unsupported/Platform.c | 2 +- unsupported/Platform.h | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/InfoScreen.c b/InfoScreen.c index 52117d0b..ecde6d91 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -20,7 +20,7 @@ static const char* const InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"}; static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27}; -InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader) { +InfoScreen* InfoScreen_init(InfoScreen* this, const Process* process, FunctionBar* bar, int height, const char* panelHeader) { this->process = process; if (!bar) { bar = FunctionBar_new(InfoScreenFunctions, InfoScreenKeys, InfoScreenEvents); diff --git a/InfoScreen.h b/InfoScreen.h index e5c58461..79927c47 100644 --- a/InfoScreen.h +++ b/InfoScreen.h @@ -29,14 +29,14 @@ typedef struct InfoScreenClass_ { struct InfoScreen_ { Object super; - Process* process; + const Process* process; Panel* display; FunctionBar* bar; IncSet* inc; Vector* lines; }; -InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader); +InfoScreen* InfoScreen_init(InfoScreen* this, const Process* process, FunctionBar* bar, int height, const char* panelHeader); InfoScreen* InfoScreen_done(InfoScreen* this); diff --git a/Process.h b/Process.h index beca4f25..664aecc7 100644 --- a/Process.h +++ b/Process.h @@ -116,7 +116,7 @@ typedef struct ProcessFieldData_ { void Process_writeField(Process* this, RichString* str, ProcessField field); long Process_compare(const void* v1, const void* v2); void Process_delete(Object* cast); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; extern char Process_pidFormat[20]; diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index d3af4788..59853770 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -45,7 +45,7 @@ void Process_delete(Object* cast) { free(this); } -bool Process_isThread(Process* this) { +bool Process_isThread(const Process* this) { (void) this; return false; } diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h index 27679582..11dc2c3c 100644 --- a/darwin/DarwinProcess.h +++ b/darwin/DarwinProcess.h @@ -26,7 +26,7 @@ DarwinProcess* DarwinProcess_new(Settings* settings); void Process_delete(Object* cast); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); void DarwinProcess_setStartTime(Process *proc, struct extern_proc *ep, time_t now); diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c index df320e08..9c5e426e 100644 --- a/dragonflybsd/DragonFlyBSDProcess.c +++ b/dragonflybsd/DragonFlyBSDProcess.c @@ -128,8 +128,8 @@ long DragonFlyBSDProcess_compare(const void* v1, const void* v2) { } } -bool Process_isThread(Process* this) { - DragonFlyBSDProcess* fp = (DragonFlyBSDProcess*) this; +bool Process_isThread(const Process* this) { + const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this; if (fp->kernel == 1 ) return 1; diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h index b33f32b2..637dddb0 100644 --- a/dragonflybsd/DragonFlyBSDProcess.h +++ b/dragonflybsd/DragonFlyBSDProcess.h @@ -41,6 +41,6 @@ void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField long DragonFlyBSDProcess_compare(const void* v1, const void* v2); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); #endif diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c index 767f485b..6548ff68 100644 --- a/freebsd/FreeBSDProcess.c +++ b/freebsd/FreeBSDProcess.c @@ -127,8 +127,8 @@ long FreeBSDProcess_compare(const void* v1, const void* v2) { } } -bool Process_isThread(Process* this) { - FreeBSDProcess* fp = (FreeBSDProcess*) this; +bool Process_isThread(const Process* this) { + const FreeBSDProcess* fp = (const FreeBSDProcess*) this; if (fp->kernel == 1 ) return 1; diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h index 80dcaf65..f6fa8b3e 100644 --- a/freebsd/FreeBSDProcess.h +++ b/freebsd/FreeBSDProcess.h @@ -39,6 +39,6 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel long FreeBSDProcess_compare(const void* v1, const void* v2); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); #endif diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 5e661e03..e6f78f9f 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -389,6 +389,6 @@ long LinuxProcess_compare(const void* v1, const void* v2) { return (diff > 0) ? 1 : (diff < 0 ? -1 : 0); } -bool Process_isThread(Process* this) { +bool Process_isThread(const Process* this) { return (Process_isUserlandThread(this) || Process_isKernelThread(this)); } diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index c1eb0ed5..9227dd7f 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -147,7 +147,7 @@ typedef struct LinuxProcess_ { char *secattr; } LinuxProcess; -#define Process_isKernelThread(_process) (((LinuxProcess*)(_process))->isKernelThread) +#define Process_isKernelThread(_process) (((const LinuxProcess*)(_process))->isKernelThread) #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) @@ -185,6 +185,6 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) long LinuxProcess_compare(const void* v1, const void* v2); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); #endif diff --git a/openbsd/OpenBSDProcess.c b/openbsd/OpenBSDProcess.c index 94ce4828..6b87f372 100644 --- a/openbsd/OpenBSDProcess.c +++ b/openbsd/OpenBSDProcess.c @@ -209,6 +209,6 @@ long OpenBSDProcess_compare(const void* v1, const void* v2) { } } -bool Process_isThread(Process* this) { +bool Process_isThread(const Process* this) { return (Process_isKernelThread(this)); } diff --git a/openbsd/OpenBSDProcess.h b/openbsd/OpenBSDProcess.h index 13f17274..bd365942 100644 --- a/openbsd/OpenBSDProcess.h +++ b/openbsd/OpenBSDProcess.h @@ -35,6 +35,6 @@ void OpenBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel long OpenBSDProcess_compare(const void* v1, const void* v2); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); #endif diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c index d0a75dfe..b796c96e 100644 --- a/solaris/SolarisProcess.c +++ b/solaris/SolarisProcess.c @@ -150,8 +150,8 @@ long SolarisProcess_compare(const void* v1, const void* v2) { } } -bool Process_isThread(Process* this) { - SolarisProcess* fp = (SolarisProcess*) this; +bool Process_isThread(const Process* this) { + const SolarisProcess* fp = (const SolarisProcess*) this; if (fp->kernel == 1 ) { return 1; diff --git a/solaris/SolarisProcess.h b/solaris/SolarisProcess.h index 6ae38331..2a32f8c7 100644 --- a/solaris/SolarisProcess.h +++ b/solaris/SolarisProcess.h @@ -58,6 +58,6 @@ void SolarisProcess_writeField(Process* this, RichString* str, ProcessField fiel long SolarisProcess_compare(const void* v1, const void* v2); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); #endif diff --git a/unsupported/Platform.c b/unsupported/Platform.c index b7fdf17d..6e8968f1 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -131,7 +131,7 @@ void Platform_setSwapValues(Meter* this) { (void) this; } -bool Process_isThread(Process* this) { +bool Process_isThread(const Process* this) { (void) this; return false; } diff --git a/unsupported/Platform.h b/unsupported/Platform.h index ce188afa..f24dcf4c 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -43,7 +43,7 @@ void Platform_setMemoryValues(Meter* this); void Platform_setSwapValues(Meter* this); -bool Process_isThread(Process* this); +bool Process_isThread(const Process* this); char* Platform_getProcessEnv(pid_t pid);