]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: reduce number of checks
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Mar 2018 17:26:58 +0000 (18:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 13 Apr 2018 09:32:46 +0000 (11:32 +0200)
We check max_bytes twice here, let's simplify that, and reduce one level
of indentation.

src/basic/copy.c

index 96d059d0e508028b15e7ae9e32798d6bdcad6363..55394871fdff0930326cdca16ae3f412b90f983a 100644 (file)
@@ -169,13 +169,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) {