From 12d7855493b456dffb63ba5edd4f9cf02028e319 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 16 Apr 2021 10:53:07 +0100 Subject: [PATCH] enter: Make it clearer that rest_argv_start always gets initialized scan-build complained that rest_argv_start could be used uninitialized, because it can't see that rest_argc >= 2 implies that rest_argv_start got initialized at the same time rest_argc was set. Make this easier to understand. Signed-off-by: Simon McVittie --- app/flatpak-builtins-enter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/flatpak-builtins-enter.c b/app/flatpak-builtins-enter.c index de7a0318..44e14e9b 100644 --- a/app/flatpak-builtins-enter.c +++ b/app/flatpak-builtins-enter.c @@ -89,6 +89,8 @@ flatpak_builtin_enter (int argc, g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); rest_argc = 0; + rest_argv_start = 0; + for (i = 1; i < argc; i++) { /* The non-option is the command, take it out of the arguments */ @@ -110,6 +112,9 @@ flatpak_builtin_enter (int argc, return FALSE; } + /* If this wasn't true, rest_argc would still be 0 */ + g_assert (rest_argv_start >= 1); + pid_s = argv[rest_argv_start]; pid = atoi (pid_s);