From 44091705dbdb2e3751c03e4935b1e5a7cf169241 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Tue, 17 May 2022 19:15:37 +0800 Subject: [PATCH] Use of NULL in execlp() must have a pointer cast. Signed-off-by: Kang-Che Sung --- OpenFilesScreen.c | 4 +++- TraceScreen.c | 4 +++- linux/SystemdMeter.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index 2d191692..787e17b9 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -120,7 +120,9 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { close(fdnull); char buffer[32] = {0}; xSnprintf(buffer, sizeof(buffer), "%d", pid); - execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", NULL); + // Use of NULL in variadic functions must have a pointer cast. + // The NULL constant is not required by standard to have a pointer type. + execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", (char *)NULL); exit(127); } close(fdpair[1]); diff --git a/TraceScreen.c b/TraceScreen.c index c3a94492..90400b43 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -90,7 +90,9 @@ bool TraceScreen_forkTracer(TraceScreen* this) { char buffer[32] = {0}; xSnprintf(buffer, sizeof(buffer), "%d", this->super.process->pid); - execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, NULL); + // Use of NULL in variadic functions must have a pointer cast. + // The NULL constant is not required by standard to have a pointer type. + execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, (char *)NULL); // Should never reach here, unless execlp fails ... const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH."; diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c index 567cfc7c..297cc253 100644 --- a/linux/SystemdMeter.c +++ b/linux/SystemdMeter.c @@ -219,6 +219,8 @@ static void updateViaExec(void) { exit(1); dup2(fdnull, STDERR_FILENO); close(fdnull); + // Use of NULL in variadic functions must have a pointer cast. + // The NULL constant is not required by standard to have a pointer type. execlp("systemctl", "systemctl", "show", @@ -227,7 +229,7 @@ static void updateViaExec(void) { "--property=NNames", "--property=NJobs", "--property=NInstalledJobs", - NULL); + (char *)NULL); exit(127); } close(fdpair[1]);