[waffle] [PATCH 4/4] wflinfo: use waffle_string_to_enum()
Emil Velikov
emil.l.velikov at gmail.com
Thu Apr 23 02:21:32 PDT 2015
On 22 April 2015 at 19:03, Frank Henigman <fjhenigman at google.com> wrote:
> Remove platform and api lists, and instead use waffle_string_to_enum()
> to parse command line platform and api arguments.
> Also use waffle_enum_to_string() when printing platform and api.
> This means it now prints "GLX" instead of "glx" and "GL_ES2" instead of
> "gles2," for example.
>
One could use tolower() or similar solution, although I'm not sure how
much we should care. After all the input is correctly parsed
regardless of the case (thanks for that).
> static bool
> parse_args(int argc, char *argv[], struct options *opts)
> {
> - bool ok;
> bool loop_get_opt = true;
> + char ename[99];
>
Bikeshed: 99 might be an overkill considering the largest one atm is
less than 20 chars.
> @@ -551,12 +491,14 @@ print_wflinfo(const struct options *opts)
> version_str = "WFLINFO_GL_ERROR";
> }
>
> - const char *platform = enum_map_to_str(platform_map, opts->platform);
> + const char *platform = waffle_enum_to_string(opts->platform);
> assert(platform != NULL);
> + platform += sizeof "WAFFLE_PLATFORM_" - 1;
Please use brackets sizeof(foo) - 1;
It might flag up as -Wpointer-arith under Android, though we can
silence that if it becomes a problem.
> printf("Waffle platform: %s\n", platform);
>
> - const char *api = enum_map_to_str(context_api_map, opts->context_api);
> + const char *api = waffle_enum_to_string(opts->context_api);
> assert(api != NULL);
> + api += sizeof "WAFFLE_CONTEXT_OPEN" - 1;
Ditto.
With the two sizeof() fixed
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
Thanks
Emil
More information about the waffle
mailing list