Use of NULL in execlp() must have a pointer cast.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This commit is contained in:
Explorer09 2022-05-17 19:15:37 +08:00
parent 87793b8555
commit 44091705db
3 changed files with 9 additions and 3 deletions

View File

@ -120,7 +120,9 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
close(fdnull); close(fdnull);
char buffer[32] = {0}; char buffer[32] = {0};
xSnprintf(buffer, sizeof(buffer), "%d", pid); 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); exit(127);
} }
close(fdpair[1]); close(fdpair[1]);

View File

@ -90,7 +90,9 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
char buffer[32] = {0}; char buffer[32] = {0};
xSnprintf(buffer, sizeof(buffer), "%d", this->super.process->pid); 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 ... // Should never reach here, unless execlp fails ...
const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH."; const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH.";

View File

@ -219,6 +219,8 @@ static void updateViaExec(void) {
exit(1); exit(1);
dup2(fdnull, STDERR_FILENO); dup2(fdnull, STDERR_FILENO);
close(fdnull); 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", execlp("systemctl",
"systemctl", "systemctl",
"show", "show",
@ -227,7 +229,7 @@ static void updateViaExec(void) {
"--property=NNames", "--property=NNames",
"--property=NJobs", "--property=NJobs",
"--property=NInstalledJobs", "--property=NInstalledJobs",
NULL); (char *)NULL);
exit(127); exit(127);
} }
close(fdpair[1]); close(fdpair[1]);