summaryrefslogtreecommitdiff
path: root/src/settings.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-02-14 16:50:32 -0800
committerVito Caputo <vcaputo@pengaru.com>2021-02-14 16:50:32 -0800
commitb31ee4be7739ccd8cf36048da212410514758949 (patch)
tree5d5a7a16f27a47c2f4fdd4e015c702526c817ae6 /src/settings.c
parent4ba92170fcc18d5c194f3bc18ea96d36adf9d9ce (diff)
*fb: improve error propagation out of setup/init
A lot of errors were being conflated as ENOMEM due to the lazy use of NULL pointer returns for errors. This commit reworks a handful of those return paths to instead return an errno-style int, storing the results on success at a supplied result pointer. It's kind of ugly, and I make some assumptions about libdrm setting errno on failure - it too uses this lazy API of returning NULL pointers on failure. Hopefully errno is always set by an underlying ioctl failing. The SDL error API is also pretty gross, being cross-platform it defines its own error codes so I try vaguely map these to errno values. I'm considering this a first approximation at fixing this up, but there are probably bugs as I did it real fast and nasty. It at least seems to all still work OK here in the non-error paths I tested. So it doesn't seem more broken than before at a glance.
Diffstat (limited to 'src/settings.c')
-rw-r--r--src/settings.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/settings.c b/src/settings.c
index aa256c5..3ba4f15 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -196,10 +196,13 @@ int settings_apply_desc_generators(const settings_t *settings, const setting_des
const setting_desc_generator_t *g = &generators[i];
const char *value;
setting_desc_t *desc;
+ int r;
- desc = g->func(setup_context);
- if (!desc)
- return -ENOMEM;
+ r = g->func(setup_context, &desc);
+ if (r < 0)
+ return r;
+
+ assert(desc);
value = settings_get_value(settings, g->key);
if (value) {
@@ -236,6 +239,7 @@ int setting_desc_clone(const setting_desc_t *desc, setting_desc_t **res_desc)
assert(desc->name);
assert(desc->preferred); /* XXX: require a preferred default? */
assert(!desc->annotations || desc->values);
+ assert(res_desc);
d = calloc(1, sizeof(setting_desc_t));
if (!d)
© All Rights Reserved