diff options
Diffstat (limited to 'bin/dd/position.c')
-rw-r--r-- | bin/dd/position.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bin/dd/position.c b/bin/dd/position.c index 74b612c..6c0f684 100644 --- a/bin/dd/position.c +++ b/bin/dd/position.c @@ -62,14 +62,16 @@ static const char rcsid[] = void pos_in() { - int bcnt, warned; - ssize_t nr; off_t cnt; + int warned; + ssize_t nr; + size_t bcnt; /* If not a character, pipe or tape device, try to seek on it. */ if (!(in.flags & (ISCHR|ISPIPE|ISTAPE)) || in.flags & ISDISK) { errno = 0; - if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 && errno) + if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 && + errno != 0) err(1, "%s", in.name); return; } @@ -79,8 +81,6 @@ pos_in() * being skipped. No differentiation for reading complete and partial * blocks for other devices. */ - if (in.offset < 0) - errx(1, "skip must be positive"); for (bcnt = in.dbsz, cnt = in.offset, warned = 0; cnt;) { if ((nr = read(in.fd, in.db, bcnt)) > 0) { if (in.flags & ISPIPE) { @@ -129,7 +129,7 @@ pos_out() if (!(out.flags & (ISCHR|ISPIPE|ISTAPE)) || out.flags & ISDISK) { errno = 0; if (lseek(out.fd, out.offset * out.dbsz, SEEK_SET) == -1 && - errno) + errno != 0) err(1, "%s", out.name); return; } @@ -145,8 +145,6 @@ pos_out() } /* Read it. */ - if (out.offset < 0) - errx(1, "seek must be positive"); for (cnt = 0; cnt < out.offset; ++cnt) { if ((n = read(out.fd, out.db, out.dbsz)) > 0) continue; |