[waffle] [PATCH 2/2] utils/wflinfo: make errors parsable

Chad Versace chad.versace at linux.intel.com
Fri Feb 7 09:46:22 PST 2014


On Wed, Jan 29, 2014 at 11:40:59AM -0800, Jordan Justen wrote:
> Previously, if there was an error, then wflinfo would
> print various not easily parsable messages to stderr.
> 
> Now, all output will be printed to stdout, and will
> follow a similar format to the normal wflinfo output.
> 
> Errors from the waffle library will show up like:
> Waffle error: 0x%x Some string
> 
> Additionally, these may be printed:
> Wflinfo error: Misc error w/o a waffle error code
> Wflinfo usage error: usage error message (see wflinfo --help)

I don't like the way the camelcase "Wflinfo" and "Waffle error" look on
stdout. It's not very unixy. But I understand the desire for consistency
with the rest of wflinfo's output.

You chose more consistency than I would, and I think that's the better
choice.

> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
>  src/utils/wflinfo.c | 34 +++++++++++++++++++---------------
>  1 file changed, 19 insertions(+), 15 deletions(-)


>  static void
> @@ -172,15 +171,15 @@ error_waffle(void)
>      const char *code = waffle_error_to_string(info->code);
>  
>      if (info->message_length > 0)
> -        error_printf("%s: %s", code, info->message);
> +        error_printf("Waffle", "0x%x %s: %s", info->code, code, info->message);
>      else
> -        error_printf("%s", code);
> +        error_printf("Waffle", "0x%x %s", info->code, code);
>  }

The new output looks like:
    Waffle error: 0x02 WAFFLE_ERROR_UNKNOWN: gbm_create_device failed
I prefer:
    Waffle error: WAFFLE_ERROR_UNKNOWN(0x02): gbm_create_device failed

But I don't want to bikeshed, and both are easy to parse.

These two patches are committed to master. Thanks.


More information about the waffle mailing list