as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:

* cleanup a bit for -Wall
* use __progname instead of "restore"
This commit is contained in:
lukem 1997-07-06 08:51:28 +00:00
parent e0acb98b94
commit 7da56091ad
6 changed files with 48 additions and 38 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */
/* $NetBSD: dirs.c,v 1.27 1997/07/06 08:51:28 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94";
#else
static char rcsid[] = "$NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $";
static char rcsid[] = "$NetBSD: dirs.c,v 1.27 1997/07/06 08:51:28 lukem Exp $";
#endif
#endif /* not lint */
@ -56,6 +56,7 @@ static char rcsid[] = "$NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $";
#include <ufs/ufs/dir.h>
#include <protocols/dumprestore.h>
#include <err.h>
#include <errno.h>
#include <paths.h>
#include <stdio.h>
@ -152,10 +153,10 @@ extractdirs(genmode)
vprintf(stdout, "Extract directories from tape\n");
(void) snprintf(dirfile, sizeof(dirfile), "%s/rstdir%d",
tmpdir, dumpdate);
tmpdir, (int)dumpdate);
if (command != 'r' && command != 'R') {
(void) snprintf(dirfile, sizeof(dirfile), "%s/rstdir%d-XXXXXX",
tmpdir, dumpdate);
tmpdir, (int)dumpdate);
if ((dfd = mkstemp(dirfile)) == -1)
err(1, "cannot mkstemp temporary file %s", dirfile);
df = fdopen(dfd, "w");
@ -167,10 +168,10 @@ extractdirs(genmode)
if (genmode != 0) {
(void) snprintf(modefile, sizeof(modefile), "%s/rstmode%d",
tmpdir, dumpdate);
tmpdir, (int)dumpdate);
if (command != 'r' && command != 'R') {
(void) snprintf(modefile, sizeof(modefile),
"%s/rstmode%d-XXXXXX", tmpdir, dumpdate);
"%s/rstmode%d-XXXXXX", tmpdir, (int)dumpdate);
if ((mfd = mkstemp(modefile)) == -1)
err(1, "cannot mkstemp temporary file %s",
modefile);
@ -475,7 +476,8 @@ rst_seekdir(dirp, loc, base)
return;
loc -= base;
if (loc < 0)
fprintf(stderr, "bad seek pointer to rst_seekdir %d\n", loc);
fprintf(stderr, "bad seek pointer to rst_seekdir %d\n",
(int)loc);
(void) lseek(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET);
dirp->dd_loc = loc & (DIRBLKSIZ - 1);
if (dirp->dd_loc != 0)
@ -603,7 +605,7 @@ setdirmodes(flags)
vprintf(stdout, "Set directory mode, owner, and times.\n");
if (command == 'r' || command == 'R')
(void) snprintf(modefile, sizeof(modefile), "%s/rstmode%d",
tmpdir, dumpdate);
tmpdir, (int)dumpdate);
if (modefile[0] == '#') {
panic("modefile not defined\n");
fprintf(stderr, "directory mode, owner, and times not set\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.4 1995/03/18 14:59:43 cgd Exp $ */
/* $NetBSD: extern.h,v 1.5 1997/07/06 08:51:29 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,6 +37,7 @@
struct entry *addentry __P((char *, ino_t, int));
long addfile __P((char *, ino_t, int));
int addwhiteout __P((char *));
void badentry __P((struct entry *, char *));
void canon __P((char *, char *));
void checkrestore __P((void));
@ -47,6 +48,7 @@ void createleaves __P((char *));
void createlinks __P((void));
long deletefile __P((char *, ino_t, int));
void deleteino __P((ino_t));
void delwhiteout __P((struct entry *));
ino_t dirlookup __P((const char *));
void dumpsymtable __P((char *, long));
void extractdirs __P((int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */
/* $NetBSD: interactive.c,v 1.11 1997/07/06 08:51:30 lukem Exp $ */
/*
* Copyright (c) 1985, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94";
#else
static char rcsid[] = "$NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $";
static char rcsid[] = "$NetBSD: interactive.c,v 1.11 1997/07/06 08:51:30 lukem Exp $";
#endif
#endif /* not lint */
@ -310,6 +310,7 @@ getcmd(curdir, cmd, name, ap)
char *curdir, *cmd, *name;
struct arglist *ap;
{
extern char *__progname; /* from crt0.o */
char *cp;
static char input[BUFSIZ];
char output[BUFSIZ];
@ -326,7 +327,7 @@ getcmd(curdir, cmd, name, ap)
* Read a command line and trim off trailing white space.
*/
do {
fprintf(stderr, "restore > ");
fprintf(stderr, "%s > ", __progname);
(void) fflush(stderr);
(void) fgets(input, BUFSIZ, terminal);
} while (!feof(terminal) && input[0] == '\n');
@ -506,6 +507,7 @@ printlist(name, basename)
char locname[MAXPATHLEN + 1];
dp = pathsearch(name);
listp = NULL;
if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
(!vflag && dp->d_ino == WINO))
return;
@ -521,7 +523,7 @@ printlist(name, basename)
}
} else {
entries = 0;
while (dp = rst_readdir(dirp))
while ((dp = rst_readdir(dirp)) != NULL)
entries++;
rst_closedir(dirp);
list = (struct afile *)malloc(entries * sizeof(struct afile));
@ -537,7 +539,7 @@ printlist(name, basename)
(void) strncpy(locname, name, MAXPATHLEN);
(void) strncat(locname, "/", MAXPATHLEN);
namelen = strlen(locname);
while (dp = rst_readdir(dirp)) {
while ((dp = rst_readdir(dirp)) != NULL) {
if (dp == NULL)
break;
if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0)
@ -652,6 +654,7 @@ formatf(list, nentry)
width = 0;
haveprefix = 0;
havepostfix = 0;
precision = 0;
bigino = ROOTINO;
endlist = &list[nentry];
for (fp = &list[0]; fp < endlist; fp++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $ */
/* $NetBSD: main.c,v 1.14 1997/07/06 08:51:30 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 9/13/94";
#else
static char rcsid[] = "$NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.14 1997/07/06 08:51:30 lukem Exp $";
#endif
#endif /* not lint */
@ -65,6 +65,8 @@ static char rcsid[] = "$NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $";
#include "restore.h"
#include "extern.h"
extern char *__progname; /* from crt0.o */
int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
int hflag = 1, mflag = 1, Nflag = 0;
char command = '\0';
@ -78,8 +80,6 @@ time_t dumptime;
time_t dumpdate;
FILE *terminal;
char *tmpdir;
uid_t uid; /* real uid */
uid_t euid; /* effective uid */
static void obsolete __P((int *, char **[]));
static void usage __P((void));
@ -95,10 +95,6 @@ main(argc, argv)
char *symtbl = "./restoresymtable";
char *p, name[MAXPATHLEN];
uid = getuid();
euid = geteuid();
(void) seteuid(uid);
if (argc < 2)
usage();
@ -291,11 +287,21 @@ static void
usage()
{
(void)fprintf(stderr, "usage: restore -i [-chmvy] [-b blocksize] [-f file] [-s fileno]\n");
(void)fprintf(stderr, " restore -R [-cvy] [-b blocksize] [-f file] [-s fileno]\n");
(void)fprintf(stderr, " restore -r [-cvy] [-b blocksize] [-f file] [-s fileno]\n");
(void)fprintf(stderr, " restore -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n");
(void)fprintf(stderr, " restore -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n");
(void)fprintf(stderr,
"usage: %s -i [-chmvy] [-b blocksize] [-f file] [-s fileno]\n",
__progname);
(void)fprintf(stderr,
"\t%s -R [-cvy] [-b blocksize] [-f file] [-s fileno]\n",
__progname);
(void)fprintf(stderr,
"\t%s -r [-cvy] [-b blocksize] [-f file] [-s fileno]\n",
__progname);
(void)fprintf(stderr,
"\t%s -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
__progname);
(void)fprintf(stderr,
"\t%s -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
__progname);
exit(1);
}
@ -363,7 +369,8 @@ obsolete(argcp, argvp)
}
/* Copy remaining arguments. */
while (*nargv++ = *argv++);
while ((*nargv++ = *argv++) != NULL)
;
/* Update argument count. */
*argcp = nargv - *argvp - 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: restore.c,v 1.10 1997/07/04 21:48:39 pk Exp $ */
/* $NetBSD: restore.c,v 1.11 1997/07/06 08:51:31 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94";
#else
static char rcsid[] = "$NetBSD: restore.c,v 1.10 1997/07/04 21:48:39 pk Exp $";
static char rcsid[] = "$NetBSD: restore.c,v 1.11 1997/07/06 08:51:31 lukem Exp $";
#endif
#endif /* not lint */
@ -169,7 +169,7 @@ removeoldleaves()
ino_t i, mydirino;
vprintf(stdout, "Mark entries to be removed.\n");
if (ep = lookupino(WINO)) {
if ((ep = lookupino(WINO)) != NULL) {
vprintf(stdout, "Delete whiteouts\n");
for ( ; ep != NULL; ep = nextep) {
nextep = ep->e_links;
@ -779,7 +779,7 @@ createlinks()
ino_t i;
char name[BUFSIZ];
if (ep = lookupino(WINO)) {
if ((ep = lookupino(WINO)) != NULL) {
vprintf(stdout, "Add whiteouts\n");
for ( ; ep != NULL; ep = ep->e_links) {
if ((ep->e_flags & NEW) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */
/* $NetBSD: tape.c,v 1.27 1997/07/06 08:51:32 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)tape.c 8.6 (Berkeley) 9/13/94";
#else
static char rcsid[] = "$NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $";
static char rcsid[] = "$NetBSD: tape.c,v 1.27 1997/07/06 08:51:32 lukem Exp $";
#endif
#endif /* not lint */
@ -90,9 +90,6 @@ int oldinofmt; /* old inode format conversion required */
int Bcvt; /* Swap Bytes (for CCI or sun) */
static int Qcvt; /* Swap quads (for sun) */
extern uid_t uid; /* real uid */
extern uid_t euid; /* effective uid */
#define FLUSHTAPEBUF() blkcnt = ntrec + 1
static void accthdr __P((struct s_spcl *));
@ -154,7 +151,6 @@ setinput(source)
}
pipein++;
}
(void) setuid(uid); /* rmthost() is the only reason to be setuid */
(void) strcpy(magtape, source);
}