clang-tidy: Enable cppcoreguidelines-pro-bounds
Modified code to address issues flagged by
cppcoreguidelines-pro-bounds-array-to-pointer-decay check.
Tested: Build and unit tests passed successfully.
Change-Id: I68f418d0dad440df685c103709589f6e78d141fb
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/watch.cpp b/watch.cpp
index 18c4dfd..35205da 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -5,6 +5,8 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
+#include <span>
+
namespace phosphor
{
namespace dump
@@ -87,7 +89,8 @@
constexpr auto maxBytes = sizeof(struct inotify_event) + NAME_MAX + 1;
uint8_t buffer[maxBytes];
- auto bytes = read(fd, buffer, maxBytes);
+ std::span<char> bufferSpan(reinterpret_cast<char*>(buffer), maxBytes);
+ auto bytes = read(fd, bufferSpan.data(), bufferSpan.size());
if (0 > bytes)
{
// Failed to read inotify event