Fix "-Werror=shadow" Error of open source nsjail accepted/tizen/unified/20210903.044531 submit/tizen/20210903.005907
authorKunhoon Baik <knhoon.baik@samsung.com>
Fri, 3 Sep 2021 00:55:02 +0000 (09:55 +0900)
committerKunhoon Baik <knhoon.baik@samsung.com>
Fri, 3 Sep 2021 00:55:02 +0000 (09:55 +0900)
The arg env of systemExe function shadows global env variable.
 - Local Function : int systemExe(const std::vector<std::string>& args, char** env);
 - Global : static __thread jmp_buf env;

-Werror=shadow options catches the issue.
Thus, the arg env of systemExe is changed to exec_env to avoid the compiler issue.

cf) This patch is not yet contributed to nsjail open source.

subproc.cc

index e573472508bf0d0db4913beec3c87d10a858248f..7792fbd697d55d13d57d493a1df4c8807c03f00e 100644 (file)
@@ -569,7 +569,7 @@ pid_t cloneProc(uintptr_t flags, int exit_signal) {
        return 0;
 }
 
-int systemExe(const std::vector<std::string>& args, char** env) {
+int systemExe(const std::vector<std::string>& args, char** exec_env) {
        bool exec_failed = false;
 
        std::vector<const char*> argv;
@@ -594,7 +594,7 @@ int systemExe(const std::vector<std::string>& args, char** env) {
 
        if (pid == 0) {
                close(sv[0]);
-               execve(argv[0], (char* const*)argv.data(), (char* const*)env);
+               execve(argv[0], (char* const*)argv.data(), (char* const*)exec_env);
                PLOG_W("execve('%s')", argv[0]);
                util::writeToFd(sv[1], "A", 1);
                exit(0);