aboutsummaryrefslogtreecommitdiffstats
path: root/src/gbm/backends
diff options
context:
space:
mode:
authorDaniel Stone <[email protected]>2017-03-23 15:09:49 +0000
committerDaniel Stone <[email protected]>2017-03-23 15:28:41 +0000
commit378025ca8b82c5f2068e202f1016450d97820d99 (patch)
tree68d6a29e15d455bfa3f8dcb14b883b31f8273cd9 /src/gbm/backends
parentec0313fd58fa1a64ec5ff7176e9fe0475f034d8c (diff)
gbm: Use unsigned for BO offset getter
The actual offset returned is uint32_t, however int64_t was used as the return type from gbm_bo_get_offset to allow negative returns to signal errors to the caller. In case of an error getting the offset, the user will also be unable to get the handle/FD, and thus have nothing to offset into. This means that returning 0 as an error value is harmless, allowing us to change the return type to uint32_t in order to avoid signed/unsigned confusion in callers. Signed-off-by: Daniel Stone <[email protected]> Cc: Ben Widawsky <[email protected]> Cc: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/gbm/backends')
-rw-r--r--src/gbm/backends/dri/gbm_dri.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 84b4dd88530..6b89229cdc0 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -710,22 +710,23 @@ gbm_dri_bo_get_stride(struct gbm_bo *_bo, int plane)
return (uint32_t)stride;
}
-static int64_t
+static uint32_t
gbm_dri_bo_get_offset(struct gbm_bo *_bo, int plane)
{
struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
int offset = 0;
- if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) {
- errno = ENOSYS;
- return -1;
- }
+ /* These error cases do not actually return an error code, as the user
+ * will also fail to obtain the handle/FD from the BO. In that case, the
+ * offset is irrelevant, as they have no buffer to offset into, so
+ * returning 0 is harmless.
+ */
+ if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar)
+ return 0;
- if (plane >= get_number_planes(dri, bo->image)) {
- errno = EINVAL;
- return -2;
- }
+ if (plane >= get_number_planes(dri, bo->image))
+ return 0;
/* Dumb images have no offset */
if (bo->image == NULL) {