From: Colin Walters Date: Fri, 3 Mar 2017 17:10:46 +0000 (-0500) Subject: Allow and start using C99 declaration-after-statement X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~40^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3219a5d0ee4bf10479363690e05400ebdab18be3;p=ostree.git Allow and start using C99 declaration-after-statement I've seen code in a few places that I think on balance is definitely better this way. Some of our functions have huge variable declaration sections. This change includes one small example where we could start using declarations after statements. A concern I had was - how does this interact with `__attribute__((cleanup))` and early returns? I tested it, and AFAICS the behavior is what you'd expect - the cleanup function isn't called if its variable isn't reachable. Closes: #718 Approved by: jlebon --- diff --git a/configure.ac b/configure.ac index 83b8f48f..7fac081b 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,6 @@ CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\ -Werror=incompatible-pointer-types \ -Werror=misleading-indentation \ -Werror=missing-include-dirs -Werror=aggregate-return \ - -Werror=declaration-after-statement \ ]) AC_SUBST(WARN_CFLAGS) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index dc0eb575..71604480 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -4309,16 +4309,14 @@ find_keyring (OstreeRepo *self, OstreeRemote *remote, GCancellable *cancellable) { - g_autoptr(GFile) remotes_d = NULL; - g_autoptr(GFile) file = NULL; - file = g_file_get_child (self->repodir, remote->keyring); + g_autoptr(GFile) file = g_file_get_child (self->repodir, remote->keyring); if (g_file_query_exists (file, cancellable)) { return g_steal_pointer (&file); } - remotes_d = get_remotes_d_dir (self); + g_autoptr(GFile) remotes_d = get_remotes_d_dir (self); if (remotes_d) { g_autoptr(GFile) file2 = g_file_get_child (remotes_d, remote->keyring);