From 08ba8862ec26f63ce75b512e932aa6e6919bf182 Mon Sep 17 00:00:00 2001 From: Jan-Simon Pendry Date: Sat, 2 Apr 1994 14:39:21 -0800 Subject: [PATCH] prettyness police SCCS-vsn: bin/dd/dd.c 8.3 SCCS-vsn: bin/dd/args.c 8.3 SCCS-vsn: bin/dd/conv.c 8.2 SCCS-vsn: bin/dd/misc.c 8.2 SCCS-vsn: bin/dd/extern.h 8.2 SCCS-vsn: bin/dd/position.c 8.2 --- usr/src/bin/dd/args.c | 152 ++++++++++++++++++++------------------ usr/src/bin/dd/conv.c | 22 +++--- usr/src/bin/dd/dd.c | 79 ++++++++++---------- usr/src/bin/dd/extern.h | 7 +- usr/src/bin/dd/misc.c | 66 +++-------------- usr/src/bin/dd/position.c | 31 ++++---- 6 files changed, 165 insertions(+), 192 deletions(-) diff --git a/usr/src/bin/dd/args.c b/usr/src/bin/dd/args.c index 6e923a3981..fa114d5aa3 100644 --- a/usr/src/bin/dd/args.c +++ b/usr/src/bin/dd/args.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1991, 1993 + * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -10,48 +10,52 @@ */ #ifndef lint -static char sccsid[] = "@(#)args.c 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)args.c 8.3 (Berkeley) %G%"; #endif /* not lint */ #include -#include + +#include #include +#include #include #include #include + #include "dd.h" #include "extern.h" -static u_long get_bsz __P((char *)); - -static void f_bs __P((char *)); -static void f_cbs __P((char *)); -static void f_conv __P((char *)); -static void f_count __P((char *)); -static void f_files __P((char *)); -static void f_ibs __P((char *)); -static void f_if __P((char *)); -static void f_obs __P((char *)); -static void f_of __P((char *)); -static void f_seek __P((char *)); -static void f_skip __P((char *)); +static int c_arg __P((const void *, const void *)); +static int c_conv __P((const void *, const void *)); +static void f_bs __P((char *)); +static void f_cbs __P((char *)); +static void f_conv __P((char *)); +static void f_count __P((char *)); +static void f_files __P((char *)); +static void f_ibs __P((char *)); +static void f_if __P((char *)); +static void f_obs __P((char *)); +static void f_of __P((char *)); +static void f_seek __P((char *)); +static void f_skip __P((char *)); +static u_long get_bsz __P((char *)); static struct arg { char *name; void (*f) __P((char *)); u_int set, noset; } args[] = { - "bs", f_bs, C_BS, C_BS|C_IBS|C_OBS|C_OSYNC, - "cbs", f_cbs, C_CBS, C_CBS, - "conv", f_conv, 0, 0, - "count", f_count, C_COUNT, C_COUNT, - "files", f_files, C_FILES, C_FILES, - "ibs", f_ibs, C_IBS, C_BS|C_IBS, - "if", f_if, C_IF, C_IF, - "obs", f_obs, C_OBS, C_BS|C_OBS, - "of", f_of, C_OF, C_OF, - "seek", f_seek, C_SEEK, C_SEEK, - "skip", f_skip, C_SKIP, C_SKIP, + { "bs", f_bs, C_BS, C_BS|C_IBS|C_OBS|C_OSYNC }, + { "cbs", f_cbs, C_CBS, C_CBS }, + { "conv", f_conv, 0, 0 }, + { "count", f_count, C_COUNT, C_COUNT }, + { "files", f_files, C_FILES, C_FILES }, + { "ibs", f_ibs, C_IBS, C_BS|C_IBS }, + { "if", f_if, C_IF, C_IF }, + { "obs", f_obs, C_OBS, C_BS|C_OBS }, + { "of", f_of, C_OF, C_OF }, + { "seek", f_seek, C_SEEK, C_SEEK }, + { "skip", f_skip, C_SKIP, C_SKIP }, }; static char *oper; @@ -61,28 +65,26 @@ static char *oper; */ void jcl(argv) - register char **argv; + char **argv; { - register struct arg *ap; - struct arg tmp; + struct arg *ap, tmp; char *arg; - static int c_arg __P((const void *, const void *)); in.dbsz = out.dbsz = 512; while (oper = *++argv) { - if ((arg = index(oper, '=')) == NULL) - err("unknown operand %s", oper); + if ((arg = strchr(oper, '=')) == NULL) + errx(1, "unknown operand %s", oper); *arg++ = '\0'; if (!*arg) - err("no value specified for %s", oper); + errx(1, "no value specified for %s", oper); tmp.name = oper; if (!(ap = (struct arg *)bsearch(&tmp, args, sizeof(args)/sizeof(struct arg), sizeof(struct arg), c_arg))) - err("unknown operand %s", tmp.name); + errx(1, "unknown operand %s", tmp.name); if (ddflags & ap->noset) - err("%s: illegal argument combination or already set", + errx(1, "%s: illegal argument combination or already set", tmp.name); ddflags |= ap->set; ap->f(arg); @@ -101,7 +103,7 @@ jcl(argv) /* Bs supersedes ibs and obs. */ if (ddflags & C_BS && ddflags & (C_IBS|C_OBS)) - warn("bs supersedes ibs and obs"); + warnx("bs supersedes ibs and obs"); } /* @@ -110,9 +112,9 @@ jcl(argv) */ if (ddflags & (C_BLOCK|C_UNBLOCK)) { if (!(ddflags & C_CBS)) - err("record operations require cbs"); + errx(1, "record operations require cbs"); if (cbsz == 0) - err("cbs cannot be zero"); + errx(1, "cbs cannot be zero"); cfunc = ddflags & C_BLOCK ? block : unblock; } else if (ddflags & C_CBS) { if (ddflags & (C_ASCII|C_EBCDIC)) { @@ -124,14 +126,14 @@ jcl(argv) cfunc = block; } } else - err("cbs meaningless if not doing record operations"); + errx(1, "cbs meaningless if not doing record operations"); if (cbsz == 0) - err("cbs cannot be zero"); + errx(1, "cbs cannot be zero"); } else cfunc = def; if (in.dbsz == 0 || out.dbsz == 0) - err("buffer sizes cannot be zero"); + errx(1, "buffer sizes cannot be zero"); /* * Read, write and seek calls take ints as arguments. Seek sizes @@ -139,15 +141,16 @@ jcl(argv) * regular files, but it's probably not worth it. */ if (in.dbsz > INT_MAX || out.dbsz > INT_MAX) - err("buffer sizes cannot be greater than %d", INT_MAX); + errx(1, "buffer sizes cannot be greater than %d", INT_MAX); if (in.offset > INT_MAX / in.dbsz || out.offset > INT_MAX / out.dbsz) - err("seek offsets cannot be larger than %d", INT_MAX); + errx(1, "seek offsets cannot be larger than %d", INT_MAX); } static int c_arg(a, b) const void *a, *b; { + return (strcmp(((struct arg *)a)->name, ((struct arg *)b)->name)); } @@ -155,6 +158,7 @@ static void f_bs(arg) char *arg; { + in.dbsz = out.dbsz = (int)get_bsz(arg); } @@ -162,6 +166,7 @@ static void f_cbs(arg) char *arg; { + cbsz = (int)get_bsz(arg); } @@ -169,6 +174,7 @@ static void f_count(arg) char *arg; { + cpy_cnt = (u_int)get_bsz(arg); if (!cpy_cnt) terminate(0); @@ -178,6 +184,7 @@ static void f_files(arg) char *arg; { + files_cnt = (int)get_bsz(arg); } @@ -185,6 +192,7 @@ static void f_ibs(arg) char *arg; { + if (!(ddflags & C_BS)) in.dbsz = (int)get_bsz(arg); } @@ -193,6 +201,7 @@ static void f_if(arg) char *arg; { + in.name = arg; } @@ -200,6 +209,7 @@ static void f_obs(arg) char *arg; { + if (!(ddflags & C_BS)) out.dbsz = (int)get_bsz(arg); } @@ -208,6 +218,7 @@ static void f_of(arg) char *arg; { + out.name = arg; } @@ -215,6 +226,7 @@ static void f_seek(arg) char *arg; { + out.offset = (u_int)get_bsz(arg); } @@ -222,6 +234,7 @@ static void f_skip(arg) char *arg; { + in.offset = (u_int)get_bsz(arg); } @@ -230,39 +243,37 @@ static struct conv { u_int set, noset; u_char *ctab; } clist[] = { - "ascii", C_ASCII, C_EBCDIC, e2a_POSIX, - "block", C_BLOCK, C_UNBLOCK, NULL, - "ebcdic", C_EBCDIC, C_ASCII, a2e_POSIX, - "ibm", C_EBCDIC, C_ASCII, a2ibm_POSIX, - "lcase", C_LCASE, C_UCASE, NULL, - "noerror", C_NOERROR, 0, NULL, - "notrunc", C_NOTRUNC, 0, NULL, - "oldascii", C_ASCII, C_EBCDIC, e2a_32V, - "oldebcdic", C_EBCDIC, C_ASCII, a2e_32V, - "oldibm", C_EBCDIC, C_ASCII, a2ibm_32V, - "osync", C_OSYNC, C_BS, NULL, - "swab", C_SWAB, 0, NULL, - "sync", C_SYNC, 0, NULL, - "ucase", C_UCASE, C_LCASE, NULL, - "unblock", C_UNBLOCK, C_BLOCK, NULL, + { "ascii", C_ASCII, C_EBCDIC, e2a_POSIX }, + { "block", C_BLOCK, C_UNBLOCK, NULL }, + { "ebcdic", C_EBCDIC, C_ASCII, a2e_POSIX }, + { "ibm", C_EBCDIC, C_ASCII, a2ibm_POSIX }, + { "lcase", C_LCASE, C_UCASE, NULL }, + { "noerror", C_NOERROR, 0, NULL }, + { "notrunc", C_NOTRUNC, 0, NULL }, + { "oldascii", C_ASCII, C_EBCDIC, e2a_32V }, + { "oldebcdic", C_EBCDIC, C_ASCII, a2e_32V }, + { "oldibm", C_EBCDIC, C_ASCII, a2ibm_32V }, + { "osync", C_OSYNC, C_BS, NULL }, + { "swab", C_SWAB, 0, NULL }, + { "sync", C_SYNC, 0, NULL }, + { "ucase", C_UCASE, C_LCASE, NULL }, + { "unblock", C_UNBLOCK, C_BLOCK, NULL }, }; static void f_conv(arg) char *arg; { - register struct conv *cp; - struct conv tmp; - static int c_conv __P((const void *, const void *)); + struct conv *cp, tmp; while (arg != NULL) { tmp.name = strsep(&arg, ","); if (!(cp = (struct conv *)bsearch(&tmp, clist, sizeof(clist)/sizeof(struct conv), sizeof(struct conv), c_conv))) - err("unknown conversion %s", tmp.name); + errx(1, "unknown conversion %s", tmp.name); if (ddflags & cp->noset) - err("%s: illegal conversion combination", tmp.name); + errx(1, "%s: illegal conversion combination", tmp.name); ddflags |= cp->set; if (cp->ctab) ctab = cp->ctab; @@ -273,6 +284,7 @@ static int c_conv(a, b) const void *a, *b; { + return (strcmp(((struct conv *)a)->name, ((struct conv *)b)->name)); } @@ -291,14 +303,14 @@ static u_long get_bsz(val) char *val; { - char *expr; u_long num, t; + char *expr; num = strtoul(val, &expr, 0); if (num == ULONG_MAX) /* Overflow. */ - err("%s: %s", oper, strerror(errno)); + err(1, "%s", oper); if (expr == val) /* No digits. */ - err("%s: illegal numeric value", oper); + errx(1, "%s: illegal numeric value", oper); switch(*expr) { case 'b': @@ -339,10 +351,10 @@ get_bsz(val) t = num; num *= get_bsz(expr + 1); if (t > num) -erange: err("%s: %s", oper, strerror(ERANGE)); +erange: errx(1, "%s: %s", oper, strerror(ERANGE)); break; default: - err("%s: illegal numeric value", oper); + errx(1, "%s: illegal numeric value", oper); } - return(num); + return (num); } diff --git a/usr/src/bin/dd/conv.c b/usr/src/bin/dd/conv.c index 13534c072d..108b10e93a 100644 --- a/usr/src/bin/dd/conv.c +++ b/usr/src/bin/dd/conv.c @@ -10,11 +10,12 @@ */ #ifndef lint -static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)conv.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include +#include #include #include "dd.h" @@ -29,8 +30,8 @@ static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) %G%"; void def() { - register int cnt; - register u_char *inp, *t; + int cnt; + u_char *inp, *t; if (t = ctab) for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp) @@ -73,9 +74,8 @@ void block() { static int intrunc; - register int ch, cnt; - register u_char *inp, *outp, *t; - int maxlen; + int ch, cnt, maxlen; + u_char *inp, *outp, *t; /* * Record truncation can cross block boundaries. If currently in a @@ -183,8 +183,8 @@ block_close() void unblock() { - register int cnt; - register u_char *inp, *t; + int cnt; + u_char *inp, *t; /* Translation and case conversion. */ if (t = ctab) @@ -216,11 +216,11 @@ unblock() void unblock_close() { - register int cnt; - register u_char *t; + int cnt; + u_char *t; if (in.dbcnt) { - warn("%s: short input record", in.name); + warnx("%s: short input record", in.name); for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t); if (t >= in.db) { cnt = t - in.db + 1; diff --git a/usr/src/bin/dd/dd.c b/usr/src/bin/dd/dd.c index 01d06754b2..ed7ba8ba84 100644 --- a/usr/src/bin/dd/dd.c +++ b/usr/src/bin/dd/dd.c @@ -16,7 +16,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)dd.c 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)dd.c 8.3 (Berkeley) %G%"; #endif /* not lint */ #include @@ -25,6 +25,7 @@ static char sccsid[] = "@(#)dd.c 8.2 (Berkeley) %G%"; #include #include +#include #include #include #include @@ -47,7 +48,6 @@ u_long cpy_cnt; /* # of blocks to copy */ u_int ddflags; /* conversion options */ u_int cbsz; /* conversion block size */ u_int files_cnt = 1; /* # of files to copy */ -int errstats; /* show statistics on error */ u_char *ctab; /* conversion table */ int @@ -58,23 +58,37 @@ main(argc, argv) jcl(argv); setup(); - (void)signal(SIGINFO, summary); + (void)signal(SIGINFO, summaryx); (void)signal(SIGINT, terminate); - for (errstats = 1; files_cnt--;) + atexit(summary); + + while (files_cnt--) dd_in(); dd_close(); - summary(0); exit(0); } static void -setup() +getfdtype(io) + IO *io; { - register u_int cnt; - struct stat sb; struct mtget mt; + struct stat sb; + + if (fstat(io->fd, &sb)) + err(1, "%s", io->name); + if (S_ISCHR(sb.st_mode)) + io->flags |= ioctl(io->fd, MTIOCGET, &mt) ? ISCHR : ISTAPE; + else if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) + io->flags |= ISPIPE; /* XXX fixed in 4.4BSD */ +} + +static void +setup() +{ + u_int cnt; if (in.name == NULL) { in.name = "stdin"; @@ -82,18 +96,13 @@ setup() } else { in.fd = open(in.name, O_RDONLY, 0); if (in.fd < 0) - err("%s: %s", in.name, strerror(errno)); + err(1, "%s", in.name); } - if (fstat(in.fd, &sb)) - err("%s: %s", in.name, strerror(errno)); - if (S_ISCHR(sb.st_mode)) - in.flags |= ioctl(in.fd, MTIOCGET, &mt) ? ISCHR : ISTAPE; - else if (lseek(in.fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) - in.flags |= ISPIPE; /* XXX fixed in 4.4BSD */ + getfdtype(&in); if (files_cnt > 1 && !(in.flags & ISTAPE)) - err("files is not supported for non-tape devices"); + errx(1, "files is not supported for non-tape devices"); if (out.name == NULL) { /* No way to check for read access here. */ @@ -113,15 +122,10 @@ setup() out.flags |= NOREAD; } if (out.fd < 0) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); } - if (fstat(out.fd, &sb)) - err("%s: %s", out.name, strerror(errno)); - if (S_ISCHR(sb.st_mode)) - out.flags |= ioctl(out.fd, MTIOCGET, &mt) ? ISCHR : ISTAPE; - else if (lseek(out.fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) - out.flags |= ISPIPE; /* XXX fixed in 4.4BSD */ + getfdtype(&out); /* * Allocate space for the input and output buffers. If not doing @@ -129,12 +133,12 @@ setup() */ if (!(ddflags & (C_BLOCK|C_UNBLOCK))) { if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) - err("%s", strerror(errno)); + err(1, NULL); out.db = in.db; } else if ((in.db = malloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL || (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); in.dbp = in.db; out.dbp = out.db; @@ -185,7 +189,7 @@ setup() static void dd_in() { - register int flags, n; + int flags, n; for (flags = ddflags;;) { if (cpy_cnt && (st.in_full + st.in_part) >= cpy_cnt) @@ -215,9 +219,9 @@ dd_in() * the warning message be followed by an I/O display. */ if (!(flags & C_NOERROR)) - err("%s: %s", in.name, strerror(errno)); - warn("%s: %s", in.name, strerror(errno)); - summary(0); + err(1, "%s", in.name); + warn("%s", in.name); + summary(); /* * If it's not a tape drive or a pipe, seek past the @@ -227,7 +231,7 @@ dd_in() */ if (!(in.flags & (ISPIPE|ISTAPE)) && lseek(in.fd, (off_t)in.dbsz, SEEK_CUR)) - warn("%s: %s", in.name, strerror(errno)); + warn("%s", in.name); /* If sync not specified, omit block and continue. */ if (!(ddflags & C_SYNC)) @@ -291,7 +295,7 @@ dd_close() else if (cfunc == unblock) unblock_close(); if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) { - bzero(out.dbp, out.dbsz - out.dbcnt); + memset(out.dbp, 0, out.dbsz - out.dbcnt); out.dbcnt = out.dbsz; } if (out.dbcnt) @@ -303,8 +307,8 @@ dd_out(force) int force; { static int warned; - register int cnt, n, nw; - register u_char *outp; + int cnt, n, nw; + u_char *outp; /* * Write one or more blocks out. The common case is writing a full @@ -328,10 +332,9 @@ dd_out(force) nw = write(out.fd, outp, cnt); if (nw <= 0) { if (nw == 0) - err("%s: end of device", out.name); + errx(1, "%s: end of device", out.name); if (errno != EINTR) - err("%s: %s", - out.name, strerror(errno)); + err(1, "%s", out.name); nw = 0; } outp += nw; @@ -348,11 +351,11 @@ dd_out(force) break; if (out.flags & ISCHR && !warned) { warned = 1; - warn("%s: short write on character device", + warnx("%s: short write on character device", out.name); } if (out.flags & ISTAPE) - err("%s: short write on tape device", out.name); + errx(1, "%s: short write on tape device", out.name); } if ((out.dbcnt -= n) < out.dbsz) break; diff --git a/usr/src/bin/dd/extern.h b/usr/src/bin/dd/extern.h index 567e042257..423f71e22b 100644 --- a/usr/src/bin/dd/extern.h +++ b/usr/src/bin/dd/extern.h @@ -8,7 +8,7 @@ * * %sccs.include.redist.c% * - * @(#)extern.h 8.1 (Berkeley) %G% + * @(#)extern.h 8.2 (Berkeley) %G% */ #include @@ -18,15 +18,14 @@ void block_close __P((void)); void dd_out __P((int)); void def __P((void)); void def_close __P((void)); -void err __P((const char *, ...)); void jcl __P((char **)); void pos_in __P((void)); void pos_out __P((void)); -void summary __P((int)); +void summary __P((void)); +void summaryx __P((int)); void terminate __P((int)); void unblock __P((void)); void unblock_close __P((void)); -void warn __P((const char *, ...)); extern IO in, out; extern STAT st; diff --git a/usr/src/bin/dd/misc.c b/usr/src/bin/dd/misc.c index 0a87326c74..92af501121 100644 --- a/usr/src/bin/dd/misc.c +++ b/usr/src/bin/dd/misc.c @@ -10,23 +10,23 @@ */ #ifndef lint -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include +#include #include #include #include +#include #include #include "dd.h" #include "extern.h" -/* ARGSUSED */ void -summary(notused) - int notused; +summary() { time_t secs; char buf[100]; @@ -57,62 +57,18 @@ summary(notused) /* ARGSUSED */ void -terminate(notused) +summaryx(notused) int notused; { - summary(0); - exit(0); -} - -#if __STDC__ -#include -#else -#include -#endif -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - extern int errstats; - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dd: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - if (errstats) - summary(0); - exit(1); - /* NOTREACHED */ + summary(); } +/* ARGSUSED */ void -#if __STDC__ -warn(const char *fmt, ...) -#else -warn(fmt, va_alist) - char *fmt; - va_dcl -#endif +terminate(notused) + int notused; { - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dd: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); + + exit(0); } diff --git a/usr/src/bin/dd/position.c b/usr/src/bin/dd/position.c index e52c9b040f..467ad2bd6e 100644 --- a/usr/src/bin/dd/position.c +++ b/usr/src/bin/dd/position.c @@ -10,16 +10,19 @@ */ #ifndef lint -static char sccsid[] = "@(#)position.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)position.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include #include #include + +#include #include -#include #include +#include + #include "dd.h" #include "extern.h" @@ -32,12 +35,12 @@ static char sccsid[] = "@(#)position.c 8.1 (Berkeley) %G%"; void pos_in() { - register int bcnt, cnt, nr, warned; + int bcnt, cnt, nr, warned; /* If not a character, pipe or tape device, try to seek on it. */ if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) { if (lseek(in.fd, (off_t)(in.offset * in.dbsz), SEEK_CUR) == -1) - err("%s: %s", in.name, strerror(errno)); + err(1, "%s", in.name); return; } @@ -63,7 +66,7 @@ pos_in() --files_cnt; continue; } - err("skip reached end of input"); + errx(1, "skip reached end of input"); } /* @@ -73,21 +76,21 @@ pos_in() */ if (ddflags & C_NOERROR) { if (!warned) { - warn("%s: %s", in.name, strerror(errno)); + warn("%s", in.name); warned = 1; - summary(0); + summary(); } continue; } - err("%s: %s", in.name, strerror(errno)); + err(1, "%s", in.name); } } void pos_out() { - register int cnt, n; struct mtop t_op; + int cnt, n; /* * If not a tape, try seeking on the file. Seeking on a pipe is @@ -97,7 +100,7 @@ pos_out() if (!(out.flags & ISTAPE)) { if (lseek(out.fd, (off_t)out.offset * out.dbsz, SEEK_SET) == -1) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); return; } @@ -107,7 +110,7 @@ pos_out() t_op.mt_count = out.offset; if (ioctl(out.fd, MTIOCTOP, &t_op) < 0) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); return; } @@ -117,7 +120,7 @@ pos_out() continue; if (n < 0) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); /* * If reach EOF, fill with NUL characters; first, back up over @@ -127,11 +130,11 @@ pos_out() t_op.mt_op = MTBSR; t_op.mt_count = 1; if (ioctl(out.fd, MTIOCTOP, &t_op) == -1) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); while (cnt++ < out.offset) if ((n = write(out.fd, out.db, out.dbsz)) != out.dbsz) - err("%s: %s", out.name, strerror(errno)); + err(1, "%s", out.name); break; } } -- 2.20.1