chiark / gitweb /
copy: reduce number of checks
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Mar 2018 17:26:58 +0000 (18:26 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
We check max_bytes twice here, let's simplify that, and reduce one level
of indentation.

src/basic/copy.c

index 7d46f56784b814de13cd4a4a068a6cff2a50d9f5..d008204a4d7f993aa389761afb1a4278d6f4fced 100644 (file)
@@ -171,13 +171,11 @@ int copy_bytes_full(
         for (;;) {
                 ssize_t n;
 
-                if (max_bytes != (uint64_t) -1) {
-                        if (max_bytes <= 0)
-                                return 1; /* return > 0 if we hit the max_bytes limit */
+                if (max_bytes <= 0)
+                        return 1; /* return > 0 if we hit the max_bytes limit */
 
-                        if (m > max_bytes)
-                                m = max_bytes;
-                }
+                if (max_bytes != UINT64_MAX && m > max_bytes)
+                        m = max_bytes;
 
                 /* First try copy_file_range(), unless we already tried */
                 if (try_cfr) {