Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compiler warnings #5362

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
run: Make it clearer that rest_argv_start is not used uninitialized
rest_argv_start is initialized whenever rest_argc != 0, so the previous
code was in fact safe; but this wasn't obvious to either a human reader
or the compiler, and some gcc versions warn here.

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Mar 20, 2023
commit 71ed81ceeae0914d7c985e358c42a295a42c3e50
5 changes: 3 additions & 2 deletions app/flatpak-builtins-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ flatpak_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
g_autoptr(FlatpakDecomposed) runtime_ref = NULL;
const char *pref;
int i;
int rest_argv_start, rest_argc;
int rest_argv_start = 0, rest_argc = 0;
g_autoptr(FlatpakContext) arg_context = NULL;
g_autofree char *id = NULL;
g_autofree char *arch = NULL;
Expand All @@ -114,7 +114,6 @@ flatpak_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
context = g_option_context_new (_("APP [ARGUMENT…] - Run an app"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);

rest_argc = 0;
for (i = 1; i < argc; i++)
{
/* The non-option is the command, take it out of the arguments */
Expand Down Expand Up @@ -155,6 +154,8 @@ flatpak_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
if (rest_argc == 0)
return usage_error (context, _("APP must be specified"), error);

/* If we get here, then rest_argv_start must have been set >= 1 */
g_assert (rest_argv_start > 0);
pref = argv[rest_argv_start];

if (!flatpak_split_partial_ref_arg (pref, FLATPAK_KINDS_APP | FLATPAK_KINDS_RUNTIME,
Expand Down