chiark / gitweb /
copy: drop _unlikely_() that isn't obviously the case
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Mar 2018 17:24:07 +0000 (18:24 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
If a tool only invokes copy_bytes() a single time the _unlikely_() will always be
wrong, and is hence not useful. Let's drop it and let the compiler
figure our what to do, instead of misleading it.

Also, some coding style imprvoements.

src/basic/copy.c

index 24a4252f96fbda1468a3e5cc0bf662044419af7c..7d46f56784b814de13cd4a4a068a6cff2a50d9f5 100644 (file)
 
 #define COPY_BUFFER_SIZE (16*1024u)
 
-static ssize_t try_copy_file_range(int fd_in, loff_t *off_in,
-                                   int fd_out, loff_t *off_out,
-                                   size_t len,
-                                   unsigned int flags) {
+static ssize_t try_copy_file_range(
+                int fd_in, loff_t *off_in,
+                int fd_out, loff_t *off_out,
+                size_t len,
+                unsigned int flags) {
+
         static int have = -1;
         ssize_t r;
 
-        if (have == false)
+        if (have == 0)
                 return -ENOSYS;
 
         r = copy_file_range(fd_in, off_in, fd_out, off_out, len, flags);
-        if (_unlikely_(have < 0))
+        if (have < 0)
                 have = r >= 0 || errno != ENOSYS;
-        if (r >= 0)
-                return r;
-        else
+        if (r < 0)
                 return -errno;
+
+        return r;
 }
 
 enum {