main: Fix subcommand usage output
authorMatthew Leeds <matthew.leeds@endlessm.com>
Fri, 4 Aug 2017 20:18:40 +0000 (13:18 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sat, 5 Aug 2017 00:55:36 +0000 (00:55 +0000)
This commit sets prgname correctly so that the "ostree subcommand
--help" output prints the subcommand rather than just "ostree".

This was removed in commit f0519e541f29 because it tripped the thread
sanitizer, but it's being added back conditionally so most users who
don't compile with -fsanitize=adress see proper help output.

Closes: #1054
Approved by: cgwalters

configure.ac
src/ostree/ot-main.c

index 58689cc04e06e930db963e568d489bf274cf0569..228ee84bdff6d78183aa0aa60bc3b2d7c36e22e4 100644 (file)
@@ -58,6 +58,19 @@ else
   AC_MSG_RESULT([no])
 fi
 AM_CONDITIONAL(BUILDOPT_ASAN, [test x$using_asan = xyes])
+AM_COND_IF([BUILDOPT_ASAN],
+  [AC_DEFINE([BUILDOPT_ASAN], 1, [Define if we are building with -fsanitize=address])])
+
+AC_MSG_CHECKING([for -fsanitize=thread in CFLAGS])
+if echo $CFLAGS | grep -q -e -fsanitize=thread; then
+  AC_MSG_RESULT([yes])
+  using_tsan=yes
+else
+  AC_MSG_RESULT([no])
+fi
+AM_CONDITIONAL(BUILDOPT_TSAN, [test x$using_tsan = xyes])
+AM_COND_IF([BUILDOPT_TSAN],
+  [AC_DEFINE([BUILDOPT_TSAN], 1, [Define if we are building with -fsanitize=thread])])
 
 # Initialize libtool
 LT_PREREQ([2.2.4])
index 56d247b486c49f10b0ac294f1cb0c2df2726d287..5b6e301d4cdb223ab931fba5339e993cb4ffa478 100644 (file)
@@ -117,6 +117,9 @@ ostree_run (int    argc,
   OstreeCommand *command;
   GError *error = NULL;
   GCancellable *cancellable = NULL;
+#ifndef BUILDOPT_TSAN
+  g_autofree char *prgname = NULL;
+#endif
   const char *command_name = NULL;
   gboolean success = FALSE;
   int in, out;
@@ -192,6 +195,11 @@ ostree_run (int    argc,
       goto out;
     }
 
+#ifndef BUILDOPT_TSAN
+  prgname = g_strdup_printf ("%s %s", g_get_prgname (), command_name);
+  g_set_prgname (prgname);
+#endif
+
   if (!command->fn (argc, argv, cancellable, &error))
     goto out;