From 89c1d3754777c9ae3105bfcf6a92f53ca0945d1b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 9 Aug 2021 11:27:08 +0200 Subject: [PATCH] Make liftoff_layer_set_property return negative errno This allows the caller to check for errors. --- include/libliftoff.h | 6 ++++-- layer.c | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/libliftoff.h b/include/libliftoff.h index 34aaa6e..697056a 100644 --- a/include/libliftoff.h +++ b/include/libliftoff.h @@ -109,9 +109,11 @@ void liftoff_layer_destroy(struct liftoff_layer *layer); * the property, the layer won't be mapped to any plane. * * Setting a zero FB_ID disables the layer. + * + * Zero is returned on success, negative errno on error. */ -void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, - uint64_t value); +int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, + uint64_t value); /** * Force composition on this layer. * diff --git a/layer.c b/layer.c index 014e967..210ca42 100644 --- a/layer.c +++ b/layer.c @@ -1,3 +1,4 @@ +#include #include #include #include "private.h" @@ -48,17 +49,16 @@ struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer, return NULL; } -void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, - uint64_t value) +int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, + uint64_t value) { struct liftoff_layer_property *props; struct liftoff_layer_property *prop; - /* TODO: better error handling */ if (strcmp(name, "CRTC_ID") == 0) { liftoff_log(LIFTOFF_ERROR, "refusing to set a layer's CRTC_ID"); - return; + return -EINVAL; } prop = layer_get_property(layer, name); @@ -67,7 +67,7 @@ void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, * sizeof(struct liftoff_layer_property)); if (props == NULL) { liftoff_log_errno(LIFTOFF_ERROR, "realloc"); - return; + return -ENOMEM; } layer->props = props; layer->props_len++; @@ -85,6 +85,8 @@ void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, layer->force_composition = false; layer->changed = true; } + + return 0; } void liftoff_layer_set_fb_composited(struct liftoff_layer *layer)