From f824cccac7311647a8bd22d193d3aac2b961a1dd Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 18 Nov 2019 12:07:36 +0200 Subject: fbs: use std::array and .at() Use std::array and .at() to get bounds checking. Signed-off-by: Tomi Valkeinen --- kms++/inc/kms++/dmabufframebuffer.h | 10 +++++----- kms++/inc/kms++/dumbframebuffer.h | 10 +++++----- kms++/inc/kms++/extframebuffer.h | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'kms++/inc') diff --git a/kms++/inc/kms++/dmabufframebuffer.h b/kms++/inc/kms++/dmabufframebuffer.h index 73c6d21..2a9182d 100644 --- a/kms++/inc/kms++/dmabufframebuffer.h +++ b/kms++/inc/kms++/dmabufframebuffer.h @@ -20,10 +20,10 @@ public: PixelFormat format() const override { return m_format; } unsigned num_planes() const override { return m_num_planes; } - uint32_t handle(unsigned plane) const { return m_planes[plane].handle; } - uint32_t stride(unsigned plane) const override { return m_planes[plane].stride; } - uint32_t size(unsigned plane) const override { return m_planes[plane].size; } - uint32_t offset(unsigned plane) const override { return m_planes[plane].offset; } + uint32_t handle(unsigned plane) const { return m_planes.at(plane).handle; } + uint32_t stride(unsigned plane) const override { return m_planes.at(plane).stride; } + uint32_t size(unsigned plane) const override { return m_planes.at(plane).size; } + uint32_t offset(unsigned plane) const override { return m_planes.at(plane).offset; } uint8_t* map(unsigned plane) override; int prime_fd(unsigned plane) override; @@ -41,7 +41,7 @@ private: }; unsigned m_num_planes; - struct FramebufferPlane m_planes[4]; + std::array m_planes; PixelFormat m_format; diff --git a/kms++/inc/kms++/dumbframebuffer.h b/kms++/inc/kms++/dumbframebuffer.h index b722615..f450b2c 100644 --- a/kms++/inc/kms++/dumbframebuffer.h +++ b/kms++/inc/kms++/dumbframebuffer.h @@ -19,10 +19,10 @@ public: PixelFormat format() const override { return m_format; } unsigned num_planes() const override { return m_num_planes; } - uint32_t handle(unsigned plane) const { return m_planes[plane].handle; } - uint32_t stride(unsigned plane) const override { return m_planes[plane].stride; } - uint32_t size(unsigned plane) const override { return m_planes[plane].size; } - uint32_t offset(unsigned plane) const override { return m_planes[plane].offset; } + uint32_t handle(unsigned plane) const { return m_planes.at(plane).handle; } + uint32_t stride(unsigned plane) const override { return m_planes.at(plane).stride; } + uint32_t size(unsigned plane) const override { return m_planes.at(plane).size; } + uint32_t offset(unsigned plane) const override { return m_planes.at(plane).offset; } uint8_t* map(unsigned plane) override; int prime_fd(unsigned plane) override; @@ -37,7 +37,7 @@ private: }; unsigned m_num_planes; - struct FramebufferPlane m_planes[4]; + std::array m_planes; PixelFormat m_format; }; diff --git a/kms++/inc/kms++/extframebuffer.h b/kms++/inc/kms++/extframebuffer.h index 0b9d08a..5239a3d 100644 --- a/kms++/inc/kms++/extframebuffer.h +++ b/kms++/inc/kms++/extframebuffer.h @@ -20,10 +20,10 @@ public: PixelFormat format() const override { return m_format; } unsigned num_planes() const override { return m_num_planes; } - uint32_t handle(unsigned plane) const { return m_planes[plane].handle; } - uint32_t stride(unsigned plane) const override { return m_planes[plane].stride; } - uint32_t size(unsigned plane) const override { return m_planes[plane].size; } - uint32_t offset(unsigned plane) const override { return m_planes[plane].offset; } + uint32_t handle(unsigned plane) const { return m_planes.at(plane).handle; } + uint32_t stride(unsigned plane) const override { return m_planes.at(plane).stride; } + uint32_t size(unsigned plane) const override { return m_planes.at(plane).size; } + uint32_t offset(unsigned plane) const override { return m_planes.at(plane).offset; } private: struct FramebufferPlane { @@ -35,7 +35,7 @@ private: }; unsigned m_num_planes; - struct FramebufferPlane m_planes[4]; + std::array m_planes; PixelFormat m_format; }; -- cgit v1.2.3