summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2017-12-13 13:48:01 +0100
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-14 08:05:57 +0000
commit5eca1836cbb2b03923a60859ce72673b73f7cca4 (patch)
tree8e2dabc5d0e2560971acb9154e922b41fe7a0bee
parentd7bb6d226dd6b9ddb79d3eb6692618346195e91a (diff)
downloadflatpak-5eca1836cbb2b03923a60859ce72673b73f7cca4.tar.gz
Fix clang warning
I got this: app/flatpak-main.c:364:20: warning: variable 'dir' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] else if (opt_installations != NULL) ^~~~~~~~~~~~~~~~~~~~~~~~~ app/flatpak-main.c:374:34: note: uninitialized use occurs here g_ptr_array_add (dirs, dir); ^~~ app/flatpak-main.c:364:16: note: remove the 'if' if its condition is always true else if (opt_installations != NULL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ app/flatpak-main.c:358:26: note: initialize the variable 'dir' to silence this warning FlatpakDir *dir; ^ = NULL However, that is never hit, its just the compiler being confuses, so we add a g_assert_not_reached() in the last else case. Reachability analysis: If opt_installations is != NULL we will at the very least take the last if, and if opt_installations == NULL, we will take the first one if !opt_user, and the second if opt_user. Closes: #1251 Approved by: alexlarsson
-rw-r--r--app/flatpak-main.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/flatpak-main.c b/app/flatpak-main.c
index a2bb4049..a34ed9e5 100644
--- a/app/flatpak-main.c
+++ b/app/flatpak-main.c
@@ -370,6 +370,8 @@ flatpak_option_context_parse (GOptionContext *context,
if (dir == NULL)
return FALSE;
}
+ else
+ g_assert_not_reached ();
g_ptr_array_add (dirs, dir);
}