diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2014-03-30 17:00:04 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2014-05-08 21:15:12 -0700 |
commit | 2486c37d2bbe846483e396761466c067aef7bb7a (patch) | |
tree | 9efe06905325b0f09190dc362de651821c8d3161 | |
parent | c3f67957e0e3513837fcac6548c4e610c5e14746 (diff) | |
download | waffle-2486c37d2bbe846483e396761466c067aef7bb7a.tar.gz |
wflinfo: Cleanup signature of wflinfo_try_create_context()
The function creates and returns two objects: a context and a config.
The context is the function's return value, and the config is an out
parameter.
Functions with asymmetric returns, I find awkard. Fix the signature to
return both objects as out parameters.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | src/utils/wflinfo.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c index 58d6446..e69886f 100644 --- a/src/utils/wflinfo.c +++ b/src/utils/wflinfo.c @@ -600,19 +600,17 @@ removeXcodeArgs(int *argc, char **argv) #endif // __APPLE__ -static struct waffle_context * +static bool wflinfo_try_create_context(const struct options *opts, - struct waffle_config **config, struct waffle_display *dpy, + struct waffle_context **out_ctx, + struct waffle_config **out_config, bool exit_on_fail) { int i; int32_t config_attrib_list[64]; - struct waffle_context *ctx; - - // Initialize outputs. - ctx = NULL; - *config = NULL; + struct waffle_context *ctx = NULL; + struct waffle_config *config = NULL; i = 0; config_attrib_list[i++] = WAFFLE_CONTEXT_API; @@ -659,17 +657,19 @@ wflinfo_try_create_context(const struct options *opts, config_attrib_list[i++] = 0; - *config = waffle_config_choose(dpy, config_attrib_list); - if (!*config) { + config = waffle_config_choose(dpy, config_attrib_list); + if (!config) { goto fail; } - ctx = waffle_context_create(*config, NULL); + ctx = waffle_context_create(config, NULL); if (!ctx) { goto fail; } - return ctx; + *out_ctx = ctx; + *out_config = config; + return true; fail: if (exit_on_fail) { @@ -678,11 +678,11 @@ fail: if (ctx) { waffle_context_destroy(ctx); } - if (*config) { - waffle_config_destroy(*config); + if (config) { + waffle_config_destroy(config); } - return NULL; + return false; } #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -692,7 +692,8 @@ wflinfo_create_context(const struct options *opts, struct waffle_config **config, struct waffle_display *dpy) { - struct waffle_context *ctx; + struct waffle_context *ctx = NULL; + bool ok = true; if (opts->context_profile != WAFFLE_NONE && opts->context_api == WAFFLE_CONTEXT_OPENGL && @@ -709,13 +710,13 @@ wflinfo_create_context(const struct options *opts, for (int i = ARRAY_SIZE(known_gl_profile_versions) - 1; i >= 0; i--) { tmp_opts.context_version = known_gl_profile_versions[i]; - ctx = wflinfo_try_create_context(&tmp_opts, config, dpy, false); - if (ctx) + ok = wflinfo_try_create_context(&tmp_opts, dpy, &ctx, config, false); + if (!ok) { break; + } } } else { - ctx = wflinfo_try_create_context(opts, config, dpy, true); - + wflinfo_try_create_context(opts, dpy, &ctx, config, true); } return ctx; |