From: Jim Meyering Date: Sun, 26 Nov 2000 21:35:53 +0000 (+0000) Subject: (skip): Perform the `records < blocksize' test X-Git-Tag: FILEUTILS-4_0_33~17 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=459b44b03db5155b66cbc683bcaa87821029ba17;p=thirdparty%2Fcoreutils.git (skip): Perform the `records < blocksize' test at the top of the loop, not at the bottom. --- diff --git a/src/dd.c b/src/dd.c index b6b3a5897f..4bcd2d1d34 100644 --- a/src/dd.c +++ b/src/dd.c @@ -805,6 +805,9 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records, { int nread; + if (count_bytes && records < blocksize) + blocksize = records; + nread = safe_read (fdesc, buf, blocksize); if (nread < 0) { @@ -817,14 +820,7 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records, if (nread == 0) break; - if (count_bytes) - { - records -= nread; - if (records < blocksize) - blocksize = records; - } - else - records--; + records -= (count_bytes ? nread : 1); } } }