[CRIU] [PATCH 07/24] compel cli: print usage to stderr in case of error

Dmitry Safonov 0x7f454c46 at gmail.com
Mon Dec 19 05:31:50 PST 2016


Hi Kir,

2016-12-17 14:22 GMT+03:00 Kir Kolyshkin <kir at openvz.org>:
> This is mainly dictated by the fact that we use stdout
> from "compel *flags" in a special way, so it should not
> be garbled by the usage info.
>
> Otherwise, for example, the following code in Makefile
>
>         CFLAGS += $(shell compel --badopt cflags)
>
> will lead to the whole usage() output to be added to compiler flags,
> which looks really really weird.
>
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
> ---
>  compel/src/main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/compel/src/main.c b/compel/src/main.c
> index 9be3c8b..c943feb 100644
> --- a/compel/src/main.c
> +++ b/compel/src/main.c
> @@ -110,7 +110,9 @@ static void cli_log(unsigned int lvl, const char *fmt, va_list parms)
>  }
>
>  static int usage(int rc) {
> -       printf(
> +       FILE *out = (rc == 0) ? stdout : stderr;
> +
> +       fprintf(out,
>  "Usage:\n"
>  "  compel [--compat] cflags | ldflags\n"
>  "  compel -f FILE -o FILE -p NAME [-l N] hgen\n"

I maybe miss something, but where is the same conversion to fprintf
for printing the list of known archs? And for options?
Some other patch in the series does something to them?
(for now, the patch looks incomplete)

Thanks,
             Dmitry


More information about the CRIU mailing list