summaryrefslogtreecommitdiffstats
path: root/bin/dd/conv.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-09-12 16:51:53 +0000
committergreen <green@FreeBSD.org>1999-09-12 16:51:53 +0000
commit4c16a85a3ff03636818f24c79ff2bc5947df9263 (patch)
tree27ec4fb5de7c3368adcff8f419831e3fad5929a9 /bin/dd/conv.c
parent24f1ee63f7883c5a3b659be2be4b666369e6142d (diff)
downloadFreeBSD-src-4c16a85a3ff03636818f24c79ff2bc5947df9263.zip
FreeBSD-src-4c16a85a3ff03636818f24c79ff2bc5947df9263.tar.gz
Even more cleanups to dd(1). This is probably the culmination of the
BDEification process of dd(1). Most of the changes are from BDE's archive. Support for negative offsets is gone again, but the case where you lseek() onto byte -1 of something from a negative offset using seek/skip is fixed; if you end up on -1, you won't get a false positive lseek failure. The biggest changes are to data types (more size_t, for instance) and argument parsing. skip/seek on /dev/{,k}mem now occurs (instead of "read until you reach the offset") due to mem devices now being D_DISK. Some const things are now correctly declared as such, and the "case table" building is better. The only thing that seems to be left to make dd(1) everything TOG wants it to be is l10n.
Diffstat (limited to 'bin/dd/conv.c')
-rw-r--r--bin/dd/conv.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/bin/dd/conv.c b/bin/dd/conv.c
index bf47410..57741aa 100644
--- a/bin/dd/conv.c
+++ b/bin/dd/conv.c
@@ -60,8 +60,9 @@ static const char rcsid[] =
void
def()
{
- int cnt;
- u_char *inp, *t;
+ u_char *inp;
+ const u_char *t;
+ size_t cnt;
if ((t = ctab) != NULL)
for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp)
@@ -103,9 +104,11 @@ def_close()
void
block()
{
+ u_char *inp, *outp;
+ const u_char *t;
+ size_t cnt, maxlen;
static int intrunc;
- int ch, cnt, maxlen;
- u_char *inp, *outp, *t;
+ int ch = -1;
/*
* Record truncation can cross block boundaries. If currently in a
@@ -147,7 +150,7 @@ block()
* input block.
*/
if (ch != '\n' && in.dbcnt < cbsz) {
- memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
+ (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
break;
}
@@ -197,7 +200,7 @@ block_close()
*/
if (in.dbcnt) {
++st.trunc;
- memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
+ (void)memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
(void)memset(out.dbp + in.dbcnt, ctab ? ctab[' '] : ' ',
cbsz - in.dbcnt);
out.dbcnt += cbsz;
@@ -214,8 +217,9 @@ block_close()
void
unblock()
{
- int cnt;
- u_char *inp, *t;
+ u_char *inp;
+ const u_char *t;
+ size_t cnt;
/* Translation and case conversion. */
if ((t = ctab) != NULL)
@@ -231,7 +235,7 @@ unblock()
;
if (t >= inp) {
cnt = t - inp + 1;
- memmove(out.dbp, inp, cnt);
+ (void)memmove(out.dbp, inp, cnt);
out.dbp += cnt;
out.dbcnt += cnt;
}
@@ -240,15 +244,15 @@ unblock()
dd_out(0);
}
if (in.dbcnt)
- memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
+ (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
in.dbp = in.db + in.dbcnt;
}
void
unblock_close()
{
- int cnt;
u_char *t;
+ size_t cnt;
if (in.dbcnt) {
warnx("%s: short input record", in.name);
@@ -256,7 +260,7 @@ unblock_close()
;
if (t >= in.db) {
cnt = t - in.db + 1;
- memmove(out.dbp, in.db, cnt);
+ (void)memmove(out.dbp, in.db, cnt);
out.dbp += cnt;
out.dbcnt += cnt;
}
OpenPOWER on IntegriCloud