From 459b44b03db5155b66cbc683bcaa87821029ba17 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 26 Nov 2000 21:35:53 +0000 Subject: [PATCH] (skip): Perform the `records < blocksize' test at the top of the loop, not at the bottom. --- src/dd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/dd.c b/src/dd.c index b6b3a5897..4bcd2d1d3 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); } } } -- 2.34.1