OSDN Git Service

minigbm: Fix cast to avoid null pointer arithmetic
authorJason Macnak <natsu@google.com>
Thu, 14 May 2020 17:57:17 +0000 (10:57 -0700)
committerCommit Bot <commit-bot@chromium.org>
Sat, 16 May 2020 02:08:37 +0000 (02:08 +0000)
'external/minigbm/cros_gralloc/gralloc0/gralloc0.cc:417:50:
error: arithmetic on a null pointer treated as a cast from
integer to pointer is a GNU extension'

BUG=b:146515640
TEST=m gralloc.minigbm

Change-Id: I2e86b676224657bdb656a45db4cfa49e84b61c2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2202518
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>

cros_gralloc/gralloc0/gralloc0.cc

index 6c49d3a..9f24a5d 100644 (file)
@@ -414,7 +414,8 @@ static int gralloc0_lock_async_ycbcr(struct gralloc_module_t const *module, buff
                        return ret;
 
                for (uint32_t plane = 0; plane < DRV_MAX_PLANES; plane++)
-                       addr[plane] = static_cast<uint8_t *>(nullptr) + offsets[plane];
+                       addr[plane] =
+                           reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offsets[plane]));
        }
 
        switch (hnd->format) {