Skip to content

Commit d346d50

Browse files
committed
Better alignment
1 parent c780075 commit d346d50

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

modules/yup_core/native/yup_Watchdog_linux.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace yup
2424

2525
class Watchdog::Impl final
2626
{
27-
inline static constexpr std::size_t bufferSize = (10 * (sizeof (struct inotify_event) + NAME_MAX + 1));
28-
2927
public:
3028
Impl (std::weak_ptr<Watchdog> owner, const File& folder)
3129
: owner (std::move (owner))
@@ -152,8 +150,10 @@ class Watchdog::Impl final
152150

153151
void threadCallback()
154152
{
153+
constexpr std::size_t bufferSize = (10 * (sizeof (struct inotify_event) + NAME_MAX + 1));
154+
std::vector<char> buffer (bufferSize, 0);
155+
155156
auto lastRenamedPath = std::optional<File> {};
156-
char buffer[bufferSize + 1] = { 0 };
157157

158158
struct pollfd pfd;
159159
pfd.fd = fd;
@@ -166,10 +166,10 @@ class Watchdog::Impl final
166166
if (threadShouldExit)
167167
break;
168168

169-
if (pollResult <= 0 || pfd.revents & POLLIN == 0)
169+
if (pollResult <= 0 || (pfd.revents & POLLIN) == 0)
170170
continue;
171171

172-
const ssize_t numRead = read (fd, buffer, bufferSize);
172+
const ssize_t numRead = read (fd, buffer.data(), bufferSize);
173173

174174
if (threadShouldExit)
175175
break;
@@ -178,7 +178,7 @@ class Watchdog::Impl final
178178
continue;
179179

180180
const inotify_event* notifyEvent = nullptr;
181-
for (const char* ptr = buffer; ptr < buffer + numRead; ptr += sizeof (struct inotify_event) + notifyEvent ? notifyEvent->len : 0)
181+
for (const char* ptr = buffer.data(); ptr < buffer.data() + numRead; ptr += sizeof (struct inotify_event) + notifyEvent ? notifyEvent->len : 0)
182182
{
183183
notifyEvent = reinterpret_cast<const inotify_event*> (ptr);
184184

0 commit comments

Comments
 (0)