[CRIU] [PATCH 07/24] compel cli: print usage to stderr in case of error
Kir Kolyshkin
kir at virtuozzo.com
Mon Dec 19 19:22:49 PST 2016
On 12/19/2016 05:31 AM, Dmitry Safonov wrote:
> 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)
Yes, the preceding patch (Subject: [PATCH 06/24] compel cli: kill --arch
option, add --compat)
kills the arch option altogether, so after it we only have a single
fprintf() call.
>
> Thanks,
> Dmitry
More information about the CRIU
mailing list