summaryrefslogtreecommitdiff
path: root/src/libcamera/log.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-12 01:21:01 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-14 15:35:24 +0200
commit5cfbbcd20731a2160206cc1d935eac2c770376ae (patch)
tree817f2ef9c3ce6aa7fb2ace65466498c8f880c60b /src/libcamera/log.cpp
parentbd4894d2596168b3435fb93b9e53dad84b2dcc7e (diff)
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>
Diffstat (limited to 'src/libcamera/log.cpp')
-rw-r--r--src/libcamera/log.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 180eb97b..45c7c2d2 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -7,6 +7,7 @@
#include "libcamera/internal/log.h"
+#include <array>
#if HAVE_BACKTRACE
#include <execinfo.h>
#endif
@@ -91,7 +92,7 @@ static const char *log_severity_name(LogSeverity severity)
"FATAL",
};
- if (static_cast<unsigned int>(severity) < ARRAY_SIZE(names))
+ if (static_cast<unsigned int>(severity) < std::size(names))
return names[severity];
else
return "UNKWN";
@@ -406,7 +407,7 @@ void Logger::backtrace()
return;
void *buffer[32];
- int num_entries = ::backtrace(buffer, ARRAY_SIZE(buffer));
+ int num_entries = ::backtrace(buffer, std::size(buffer));
char **strings = backtrace_symbols(buffer, num_entries);
if (!strings)
return;
@@ -620,7 +621,7 @@ LogSeverity Logger::parseLogLevel(const std::string &level)
severity = LogInvalid;
} else {
severity = LogInvalid;
- for (unsigned int i = 0; i < ARRAY_SIZE(names); ++i) {
+ for (unsigned int i = 0; i < std::size(names); ++i) {
if (names[i] == level) {
severity = i;
break;