Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/restore Simplify silly code and make it closer to type-...
details: https://anonhg.NetBSD.org/src/rev/dcecdf5055d3
branches: trunk
changeset: 768023:dcecdf5055d3
user: dholland <dholland%NetBSD.org@localhost>
date: Sat Aug 06 17:01:06 2011 +0000
description:
Simplify silly code and make it closer to type-safe. This causes amd64
gcc to reorder two pairs of instructions for some reason but the object
files are otherwise unchanged.
diffstat:
sbin/restore/restore.h | 4 ++--
sbin/restore/tape.c | 26 +++++++++++++-------------
2 files changed, 15 insertions(+), 15 deletions(-)
diffs (96 lines):
diff -r 2775268dd4a0 -r dcecdf5055d3 sbin/restore/restore.h
--- a/sbin/restore/restore.h Sat Aug 06 16:48:57 2011 +0000
+++ b/sbin/restore/restore.h Sat Aug 06 17:01:06 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: restore.h,v 1.18 2005/06/27 01:55:52 christos Exp $ */
+/* $NetBSD: restore.h,v 1.19 2011/08/06 17:01:06 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -73,7 +73,7 @@
const char *dd_name;
void (*dd_init)(void *);
void (*dd_update)(void *, const u_char *, u_int);
- char *(*dd_end)(void *, void *);
+ char *(*dd_end)(void *, char *);
};
extern const struct digest_desc *ddesc;
extern const struct digest_desc md5_desc;
diff -r 2775268dd4a0 -r dcecdf5055d3 sbin/restore/tape.c
--- a/sbin/restore/tape.c Sat Aug 06 16:48:57 2011 +0000
+++ b/sbin/restore/tape.c Sat Aug 06 17:01:06 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tape.c,v 1.63 2009/04/07 12:38:13 lukem Exp $ */
+/* $NetBSD: tape.c,v 1.64 2011/08/06 17:01:06 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: tape.c,v 1.63 2009/04/07 12:38:13 lukem Exp $");
+__RCSID("$NetBSD: tape.c,v 1.64 2011/08/06 17:01:06 dholland Exp $");
#endif
#endif /* not lint */
@@ -98,15 +98,15 @@
{ "MD5",
(void (*)(void *))MD5Init,
(void (*)(void *, const u_char *, u_int))MD5Update,
- (char *(*)(void *, void *))MD5End, },
+ (char *(*)(void *, char *))MD5End, },
{ "SHA1",
(void (*)(void *))SHA1Init,
(void (*)(void *, const u_char *, u_int))SHA1Update,
- (char *(*)(void *, void *))SHA1End, },
+ (char *(*)(void *, char *))SHA1End, },
{ "RMD160",
(void (*)(void *))RMD160Init,
(void (*)(void *, const u_char *, u_int))RMD160Update,
- (char *(*)(void *, void *))RMD160End, },
+ (char *(*)(void *, char *))RMD160End, },
{ .dd_name = NULL },
};
@@ -116,11 +116,11 @@
RMD160_CTX dc_rmd160;
} dcontext;
-union digest_buffer {
- char db_md5[32 + 1];
- char db_sha1[40 + 1];
- char db_rmd160[40 + 1];
-};
+/*
+ * 32 for md5; 40 for sha1 and rmd160
+ * plus a null terminator.
+ */
+#define DIGEST_BUFFER_SIZE (40 + 1)
#define FLUSHTAPEBUF() blkcnt = ntrec + 1
@@ -589,7 +589,7 @@
int
extractfile(char *name)
{
- union digest_buffer dbuffer;
+ char dbuffer[DIGEST_BUFFER_SIZE];
int flags;
uid_t uid;
gid_t gid;
@@ -739,12 +739,12 @@
(*ddesc->dd_init)(&dcontext);
getfile(xtrfile, xtrskip);
if (Dflag) {
- (*ddesc->dd_end)(&dcontext, &dbuffer);
+ (*ddesc->dd_end)(&dcontext, dbuffer);
for (ep = lookupname(name); ep != NULL;
ep = ep->e_links)
fprintf(stdout, "%s (%s) = %s\n",
ddesc->dd_name, myname(ep),
- (char *)&dbuffer);
+ dbuffer);
}
if (Nflag)
return (GOOD);
Home |
Main Index |
Thread Index |
Old Index