mirror of
https://passt.top/passt
synced 2024-12-22 21:55:22 +00:00
clang-tidy: Fix spurious null pointer warning in pasta_start_ns()
clang-tidy isn't quite clever enough to figure out that getenv("SHELL") will return the same thing both times here, which makes it conclude that shell could be NULL, causing problems later. It's a bit ugly that we call getenv() twice in any case, so rework this in a way that clang-tidy can figure out shell won't be NULL. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
798b7ff1c0
commit
5823dc5c68
5
pasta.c
5
pasta.c
@ -184,7 +184,7 @@ void pasta_start_ns(struct ctx *c, int argc, char *argv[])
|
|||||||
struct pasta_setup_ns_arg arg = {
|
struct pasta_setup_ns_arg arg = {
|
||||||
.argv = argv,
|
.argv = argv,
|
||||||
};
|
};
|
||||||
char *shell = getenv("SHELL") ? getenv("SHELL") : "/bin/sh";
|
char *shell = getenv("SHELL");
|
||||||
char *sh_argv[] = { shell, NULL };
|
char *sh_argv[] = { shell, NULL };
|
||||||
char *bash_argv[] = { shell, "-l", NULL };
|
char *bash_argv[] = { shell, "-l", NULL };
|
||||||
char ns_fn_stack[NS_FN_STACK_SIZE];
|
char ns_fn_stack[NS_FN_STACK_SIZE];
|
||||||
@ -193,6 +193,9 @@ void pasta_start_ns(struct ctx *c, int argc, char *argv[])
|
|||||||
if (!c->debug)
|
if (!c->debug)
|
||||||
c->quiet = 1;
|
c->quiet = 1;
|
||||||
|
|
||||||
|
if (!shell)
|
||||||
|
shell = "/bin/sh";
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
if (strstr(shell, "/bash")) {
|
if (strstr(shell, "/bash")) {
|
||||||
arg.argv = bash_argv;
|
arg.argv = bash_argv;
|
||||||
|
Loading…
Reference in New Issue
Block a user