Make liftoff_layer_set_property return negative errno

This allows the caller to check for errors.
This commit is contained in:
Simon Ser 2021-08-09 11:27:08 +02:00
parent 516cf9404d
commit 89c1d37547
2 changed files with 11 additions and 7 deletions

View file

@ -109,9 +109,11 @@ void liftoff_layer_destroy(struct liftoff_layer *layer);
* the property, the layer won't be mapped to any plane. * the property, the layer won't be mapped to any plane.
* *
* Setting a zero FB_ID disables the layer. * 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, int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name,
uint64_t value); uint64_t value);
/** /**
* Force composition on this layer. * Force composition on this layer.
* *

12
layer.c
View file

@ -1,3 +1,4 @@
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "private.h" #include "private.h"
@ -48,17 +49,16 @@ struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer,
return NULL; return NULL;
} }
void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, int liftoff_layer_set_property(struct liftoff_layer *layer, const char *name,
uint64_t value) uint64_t value)
{ {
struct liftoff_layer_property *props; struct liftoff_layer_property *props;
struct liftoff_layer_property *prop; struct liftoff_layer_property *prop;
/* TODO: better error handling */
if (strcmp(name, "CRTC_ID") == 0) { if (strcmp(name, "CRTC_ID") == 0) {
liftoff_log(LIFTOFF_ERROR, liftoff_log(LIFTOFF_ERROR,
"refusing to set a layer's CRTC_ID"); "refusing to set a layer's CRTC_ID");
return; return -EINVAL;
} }
prop = layer_get_property(layer, name); 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)); * sizeof(struct liftoff_layer_property));
if (props == NULL) { if (props == NULL) {
liftoff_log_errno(LIFTOFF_ERROR, "realloc"); liftoff_log_errno(LIFTOFF_ERROR, "realloc");
return; return -ENOMEM;
} }
layer->props = props; layer->props = props;
layer->props_len++; layer->props_len++;
@ -85,6 +85,8 @@ void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name,
layer->force_composition = false; layer->force_composition = false;
layer->changed = true; layer->changed = true;
} }
return 0;
} }
void liftoff_layer_set_fb_composited(struct liftoff_layer *layer) void liftoff_layer_set_fb_composited(struct liftoff_layer *layer)