Enable bugprone-terminating-continue clang-tidy check
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 18 Aug 2020 19:58:51 +0000 (21:58 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 1 Sep 2020 06:37:03 +0000 (06:37 +0000)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
.clang-tidy
src/gui/folderwatcher_linux.cpp

index 302f6a3cebc0b9404ac19d25030476db66de4e71..436a6c7decb6c0dfc3faa44a1bbe5ec80f9dbee3 100644 (file)
@@ -5,6 +5,7 @@ Checks: '-*,
     bugprone-macro-parentheses,
     bugprone-narrowing-conversions,
     bugprone-too-small-loop-variable,
+    bugprone-terminating-continue,
     cppcoreguidelines-init-variables,
     misc-*,
     -misc-non-private-member-variables-in-classes,
index 9ab9ab8541c4bda5b59a911d3817cdb63d70de8b..a5215b3b5731b7197ca89066dfc33b0eaa280868 100644 (file)
@@ -132,25 +132,25 @@ void FolderWatcherPrivate::slotReceivedNotification(int fd)
     int error = 0;
     QVarLengthArray<char, 2048> buffer(2048);
 
-    do {
+    len = read(fd, buffer.data(), buffer.size());
+    error = errno;
+    /**
+      * From inotify documentation:
+      *
+      * The behavior when the buffer given to read(2) is too
+      * small to return information about the next event
+      * depends on the kernel version: in kernels  before 2.6.21,
+      * read(2) returns 0; since kernel 2.6.21, read(2) fails with
+      * the error EINVAL.
+      */
+    while (len < 0 && error == EINVAL) {
+        // double the buffer size
+        buffer.resize(buffer.size() * 2);
+
+        /* and try again ... */
         len = read(fd, buffer.data(), buffer.size());
         error = errno;
-        /**
-          * From inotify documentation:
-          *
-          * The behavior when the buffer given to read(2) is too
-          * small to return information about the next event
-          * depends on the kernel version: in kernels  before 2.6.21,
-          * read(2) returns 0; since kernel 2.6.21, read(2) fails with
-          * the error EINVAL.
-          */
-        if (len < 0 && error == EINVAL) {
-            // double the buffer size
-            buffer.resize(buffer.size() * 2);
-            /* and try again ... */
-            continue;
-        }
-    } while (false);
+    }
 
     // reset counter
     i = 0;