libcamera: Replace ARRAY_SIZE() with std::size()

C++17 has a std::size() function that returns the size of a C-style
array. Use it instead of the custom ARRAY_SIZE macro.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart
2020-12-12 01:21:01 +02:00
parent bd4894d259
commit 5cfbbcd207
7 changed files with 16 additions and 22 deletions

View File

@@ -7,6 +7,7 @@
#include <libcamera/camera.h>
#include <array>
#include <atomic>
#include <iomanip>
@@ -17,7 +18,6 @@
#include "libcamera/internal/log.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/thread.h"
#include "libcamera/internal/utils.h"
/**
* \file camera.h
@@ -393,7 +393,7 @@ int Camera::Private::isAccessAllowed(State state, bool allowDisconnected) const
if (currentState == state)
return 0;
ASSERT(static_cast<unsigned int>(state) < ARRAY_SIZE(camera_state_names));
ASSERT(static_cast<unsigned int>(state) < std::size(camera_state_names));
LOG(Camera, Debug) << "Camera in " << camera_state_names[currentState]
<< " state trying operation requiring state "
@@ -412,8 +412,8 @@ int Camera::Private::isAccessAllowed(State low, State high,
if (currentState >= low && currentState <= high)
return 0;
ASSERT(static_cast<unsigned int>(low) < ARRAY_SIZE(camera_state_names) &&
static_cast<unsigned int>(high) < ARRAY_SIZE(camera_state_names));
ASSERT(static_cast<unsigned int>(low) < std::size(camera_state_names) &&
static_cast<unsigned int>(high) < std::size(camera_state_names));
LOG(Camera, Debug) << "Camera in " << camera_state_names[currentState]
<< " state trying operation requiring state between "