tree-wide: Squash noncritical compiler warnings

Should fix everything from
<https://kojipkgs.fedoraproject.org//packages/ostree/2017.2/3.fc25/data/logs/x86_64/build.log>

Anything that uses autocleanups should *always* be initialized directly I think,
even if a few lines down we directly assign, since this way it's more robust
against refactoring.

And the `freopen()` warnings are right - IMO we should *always* check return
values.

Closes: #711
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-02-24 09:33:20 -05:00 committed by Atomic Bot
parent a71d550860
commit 877a27da0f
4 changed files with 10 additions and 7 deletions

View File

@ -520,7 +520,7 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
} }
else else
{ {
g_autoptr(GFile) log_file; g_autoptr(GFile) log_file = NULL;
GFileOutputStream* log_stream; GFileOutputStream* log_stream;
log_file = g_file_new_for_path (opt_log); log_file = g_file_new_for_path (opt_log);
@ -601,9 +601,12 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
if (setsid () < 0) if (setsid () < 0)
err (1, "setsid"); err (1, "setsid");
/* Daemonising: close stdout/stderr so $() et al work on us */ /* Daemonising: close stdout/stderr so $() et al work on us */
freopen("/dev/null", "r", stdin); if (freopen("/dev/null", "r", stdin) == NULL)
freopen("/dev/null", "w", stdout); err (1, "freopen");
freopen("/dev/null", "w", stderr); if (freopen("/dev/null", "w", stdout) == NULL)
err (1, "freopen");
if (freopen("/dev/null", "w", stderr) == NULL)
err (1, "freopen");
} }
else else
{ {

View File

@ -125,7 +125,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
if (!subcommand->name) if (!subcommand->name)
{ {
g_autoptr(GOptionContext) context = NULL; g_autoptr(GOptionContext) context = NULL;
g_autofree char *help; g_autofree char *help = NULL;
context = ostree_admin_option_context_new_with_commands (); context = ostree_admin_option_context_new_with_commands ();

View File

@ -114,7 +114,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
if (!subcommand->name) if (!subcommand->name)
{ {
g_autoptr(GOptionContext) context = NULL; g_autoptr(GOptionContext) context = NULL;
g_autofree char *help; g_autofree char *help = NULL;
context = remote_option_context_new_with_commands (); context = remote_option_context_new_with_commands ();

View File

@ -171,7 +171,7 @@ ostree_run (int argc,
if (!command->fn) if (!command->fn)
{ {
g_autoptr(GOptionContext) context = NULL; g_autoptr(GOptionContext) context = NULL;
g_autofree char *help; g_autofree char *help = NULL;
context = ostree_option_context_new_with_commands (commands); context = ostree_option_context_new_with_commands (commands);