diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-11-10 18:49:28 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-11-10 18:49:28 -0800 |
commit | 44ec797349713f28314bd329bee940cd55fad411 (patch) | |
tree | 2128c6ba385d4969b30b54259791811df315daf4 /src/drm_fb.c | |
parent | 4b82076cb381f91c1225eb39efa924e935043d8b (diff) |
settings: s/setting_desc_new/setting_desc_clone/
Slight refactor to make call sites less annoying.
Now takes a (setting_desc_t *) instead of the members as discrete
parameters, and returns an errno on error so callers can simply
propagate error codes out rather than having to get access to errno
defines, check for NULL and return -ENOMEM etc.
It also makes the call sites self documenting by employing designated
initializers in compound literals for the supplied setting_desc_t.
This is in prep for runtime-configurable module settings.
Diffstat (limited to 'src/drm_fb.c')
-rw-r--r-- | src/drm_fb.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c index 6599d9d..3d0f6ba 100644 --- a/src/drm_fb.c +++ b/src/drm_fb.c @@ -70,12 +70,18 @@ static const char * connector_type_name(uint32_t type) { static setting_desc_t * dev_desc_generator(void *setup_context) { - return setting_desc_new("DRM Device Path", - "dev", - "/dev/dri/card[0-9]", - "/dev/dri/card0", - NULL, - NULL); + setting_desc_t *desc = NULL; + + (void) setting_desc_clone(&(setting_desc_t){ + .name = "DRM Device Path", + .key = "dev", + .regex = "/dev/dri/card[0-9]", + .preferred = "/dev/dri/card0", + .values = NULL, + .annotations = NULL + }, &desc); + + return desc; } @@ -145,18 +151,20 @@ static setting_desc_t * connector_desc_generator(void *setup_context) { drm_fb_setup_t *s = setup_context; const char **connectors; - setting_desc_t *desc; + setting_desc_t *desc = NULL; connectors = get_connectors(s->dev); if (!connectors) return NULL; - desc = setting_desc_new("DRM Connector", - "connector", - "[a-zA-Z0-9]+", - connectors[0], - connectors, - NULL); + (void) setting_desc_clone(&(setting_desc_t){ + .name = "DRM Connector", + .key = "connector", + .regex = "[a-zA-Z0-9]+", + .preferred = connectors[0], + .values = connectors, + .annotations = NULL + }, &desc); free_strv(connectors); @@ -239,19 +247,21 @@ _out: static setting_desc_t * mode_desc_generator(void *setup_context) { drm_fb_setup_t *s = setup_context; - setting_desc_t *desc; + setting_desc_t *desc = NULL; const char **modes; modes = get_modes(s->dev, s->connector); if (!modes) return NULL; - desc = setting_desc_new("DRM Video Mode", - "mode", - "[0-9]+[xX][0-9]+@[0-9]+", - modes[0], - modes, - NULL); + (void) setting_desc_clone(&(setting_desc_t){ + .name = "DRM Video Mode", + .key = "mode", + .regex = "[0-9]+[xX][0-9]+@[0-9]+", + .preferred = modes[0], + .values = modes, + .annotations = NULL + }, &desc); free_strv(modes); |