From cb1c4f11bb5a6d49cdace13531fdfe1d1b87b591 Mon Sep 17 00:00:00 2001 From: christos Date: Mon, 27 Jun 2005 01:55:52 +0000 Subject: [PATCH] sprinkle const. --- sbin/restore/dirs.c | 6 +++--- sbin/restore/extern.h | 31 ++++++++++++++++--------------- sbin/restore/interactive.c | 10 +++++----- sbin/restore/main.c | 13 +++++++------ sbin/restore/restore.c | 6 +++--- sbin/restore/restore.h | 6 +++--- sbin/restore/symtab.c | 21 +++++++++++---------- sbin/restore/tape.c | 16 +++++++++------- sbin/restore/utilities.c | 10 +++++----- 9 files changed, 62 insertions(+), 57 deletions(-) diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 809b5d52c771..1f8cbe6bc8a1 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $NetBSD: dirs.c,v 1.43 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: dirs.c,v 1.44 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)dirs.c 8.7 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: dirs.c,v 1.43 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: dirs.c,v 1.44 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -226,7 +226,7 @@ skipdirs(void) * pname and pass them off to be processed. */ void -treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int)) +treescan(const char *pname, ino_t ino, long (*todo)(const char *, ino_t, int)) { struct inotab *itp; struct direct *dp; diff --git a/sbin/restore/extern.h b/sbin/restore/extern.h index 1353b2c4032f..b10eba067552 100644 --- a/sbin/restore/extern.h +++ b/sbin/restore/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.12 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: extern.h,v 1.13 2005/06/27 01:55:52 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -31,16 +31,16 @@ * @(#)extern.h 8.2 (Berkeley) 1/7/94 */ -struct entry *addentry(char *, ino_t, int); +struct entry *addentry(const char *, ino_t, int); long addfile(char *, ino_t, int); int addwhiteout(char *); -void badentry(struct entry *, char *); -void canon(char *, char *); +void badentry(struct entry *, const char *); +void canon(const char *, char *); void checkrestore(void); void cleanup(void); void closemt(void); void createfiles(void); -void createleaves(char *); +void createleaves(const char *); void createlinks(void); long deletefile(char *, ino_t, int); void deleteino(ino_t); @@ -48,7 +48,7 @@ void delwhiteout(struct entry *); const struct digest_desc * digest_lookup(const char *); ino_t dirlookup(const char *); -void dumpsymtable(char *, int32_t); +void dumpsymtable(const char *, int32_t); void extractdirs(int); int extractfile(char *); void findunreflinks(void); @@ -59,11 +59,11 @@ int genliteraldir(char *, ino_t); char *gentempname(struct entry *); void getfile(void (*)(char *, long), void (*)(char *, long)); void getvol(int); -void initsymtable(char *); +void initsymtable(const char *); int inodetype(ino_t); int linkit(char *, char *, int); struct entry *lookupino(ino_t); -struct entry *lookupname(char *); +struct entry *lookupname(const char *); long listfile(char *, ino_t, int); ino_t lowerbnd(ino_t); void mktempname(struct entry *); @@ -85,20 +85,21 @@ void removenode(struct entry *); void removeoldleaves(void); void removeoldnodes(void); void renameit(char *, char *); -int reply(char *); +int reply(const char *); RST_DIR *rst_opendir(const char *); struct direct *rst_readdir(RST_DIR *); void rst_closedir(RST_DIR *); void runcmdshell(void); -char *savename(char *); +char *savename(const char *); void setdirmodes(int); -void setinput(char *); +void setinput(const char *); void setup(void); void skipdirs(void); void skipfile(void); void skipmaps(void); void swabst(u_char *, u_char *); -void treescan(char *, ino_t, long (*)(char *, ino_t, int)); +void treescan(const char *, ino_t, + long (*)(const char *, ino_t, int)); ino_t upperbnd(ino_t); long verifyfile(char *, ino_t, int); void writemtree(const char *, const char *, const uid_t, @@ -107,8 +108,8 @@ void xtrnull(char *, long); /* From ../dump/dumprmt.c */ void rmtclose(void); -int rmthost(char *); +int rmthost(const char *); int rmtioctl(int, int); -int rmtopen(char *, int); -int rmtread(char *, int); +int rmtopen(const char *, int); +int rmtread(const char *, int); int rmtseek(int, int); diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index 2ed668ff39a7..14c6517067ba 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -1,4 +1,4 @@ -/* $NetBSD: interactive.c,v 1.21 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: interactive.c,v 1.22 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1985, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)interactive.c 8.5 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: interactive.c,v 1.21 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: interactive.c,v 1.22 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -457,7 +457,7 @@ copynext(char *input, char *output) * remove any imbedded "." and ".." components. */ void -canon(char *rawname, char *canonname) +canon(const char *rawname, char *canonname) { char *cp, *np; @@ -763,8 +763,8 @@ glob_stat(const char *name, struct stat *stp) static int fcmp(const void *f1, const void *f2) { - return (strcmp(((struct afile *)f1)->fname, - ((struct afile *)f2)->fname)); + return (strcmp(((const struct afile *)f1)->fname, + ((const struct afile *)f2)->fname)); } /* diff --git a/sbin/restore/main.c b/sbin/restore/main.c index 3dd011494b85..3647072971e2 100644 --- a/sbin/restore/main.c +++ b/sbin/restore/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.30 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: main.c,v 1.31 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: main.c,v 1.30 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: main.c,v 1.31 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -75,7 +75,7 @@ time_t dumptime; time_t dumpdate; size_t pagesize; FILE *terminal; -char *tmpdir; +const char *tmpdir; int dotflag = 0; FILE *Mtreefile = NULL; @@ -88,9 +88,10 @@ main(int argc, char *argv[]) { int ch; ino_t ino; - char *inputdev; - char *symtbl = "./restoresymtable"; + const char *inputdev; + const char *symtbl = "./restoresymtable"; char *p, name[MAXPATHLEN]; + static char dot[] = "."; if (argc < 2) usage(); @@ -193,7 +194,7 @@ main(int argc, char *argv[]) if (argc == 0) { argc = 1; - *--argv = "."; + *--argv = dot; } switch (command) { diff --git a/sbin/restore/restore.c b/sbin/restore/restore.c index 3d1ae76c09f3..c0d8f2b47346 100644 --- a/sbin/restore/restore.c +++ b/sbin/restore/restore.c @@ -1,4 +1,4 @@ -/* $NetBSD: restore.c,v 1.16 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: restore.c,v 1.17 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94"; #else -__RCSID("$NetBSD: restore.c,v 1.16 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: restore.c,v 1.17 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -589,7 +589,7 @@ removeoldnodes(void) * Extract new leaves. */ void -createleaves(char *symtabfile) +createleaves(const char *symtabfile) { struct entry *ep; ino_t first; diff --git a/sbin/restore/restore.h b/sbin/restore/restore.h index c33c4c49c2a3..7bc0862d7ba4 100644 --- a/sbin/restore/restore.h +++ b/sbin/restore/restore.h @@ -1,4 +1,4 @@ -/* $NetBSD: restore.h,v 1.17 2005/01/08 14:30:39 fredb Exp $ */ +/* $NetBSD: restore.h,v 1.18 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -64,7 +64,7 @@ extern time_t dumpdate; /* time that this dump was made */ extern char command; /* opration being performed */ extern size_t pagesize; /* system page size */ extern FILE *terminal; /* file descriptor for the terminal input */ -extern char *tmpdir; /* where to store temporary files */ +extern const char *tmpdir; /* where to store temporary files */ extern int oldinofmt; /* reading tape with old format inodes */ extern int Bcvt; /* need byte swapping on inodes and dirs */ extern FILE *Mtreefile; /* file descriptor for the mtree file */ @@ -133,7 +133,7 @@ struct context { int mtime_nsec; /* modified time nanoseconds */ int birthtime_nsec; /* creation time nanoseconds */ off_t size; /* size of file */ - char *name; /* name of file */ + const char *name; /* name of file */ } curfile; /* actions */ #define USING 1 /* extracting from the tape */ diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c index 060cc8016ef4..f688a51ea7c9 100644 --- a/sbin/restore/symtab.c +++ b/sbin/restore/symtab.c @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.20 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: symtab.c,v 1.21 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)symtab.c 8.3 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: symtab.c,v 1.20 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.21 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -74,7 +74,7 @@ static struct entry **entry; static long entrytblsize; static void addino(ino_t, struct entry *); -static struct entry *lookupparent(char *); +static struct entry *lookupparent(const char *); static void removeentry(struct entry *); /* @@ -140,10 +140,11 @@ deleteino(ino_t inum) * Look up an entry by name */ struct entry * -lookupname(char *name) +lookupname(const char *name) { struct entry *ep; - char *np, *cp; + char *np; + const char *cp; char buf[MAXPATHLEN]; cp = name; @@ -166,7 +167,7 @@ lookupname(char *name) * Look up the parent of a pathname */ static struct entry * -lookupparent(char *name) +lookupparent(const char *name) { struct entry *ep; char *tailindex; @@ -215,7 +216,7 @@ static struct entry *freelist = NULL; * add an entry to the symbol table */ struct entry * -addentry(char *name, ino_t inum, int type) +addentry(const char *name, ino_t inum, int type) { struct entry *np, *ep; @@ -384,7 +385,7 @@ static struct strhdr strtblhdr[allocsize(NAME_MAX) / STRTBLINCR]; * has an appropriate sized entry, and if not allocates a new one. */ char * -savename(char *name) +savename(const char *name) { struct strhdr *np, *tp; long len, siz; @@ -444,7 +445,7 @@ struct symtableheader { * dump a snapshot of the symbol table */ void -dumpsymtable(char *filename, int32_t checkpt) +dumpsymtable(const char *filename, int32_t checkpt) { struct entry *ep, *tep; ino_t i; @@ -530,7 +531,7 @@ dumpsymtable(char *filename, int32_t checkpt) * Initialize a symbol table from a file */ void -initsymtable(char *filename) +initsymtable(const char *filename) { char *base; long tblsize; diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 67f70300e373..16f41a4a7814 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1,4 +1,4 @@ -/* $NetBSD: tape.c,v 1.52 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: tape.c,v 1.53 2005/06/27 01:55:52 christos 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.52 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: tape.c,v 1.53 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -83,7 +83,7 @@ static int tapesread; static jmp_buf restart; static int gettingfile = 0; /* restart has a valid frame */ #ifdef RRESTORE -static char *host = NULL; +static const char *host = NULL; #endif static int ofile; @@ -186,8 +186,9 @@ digest_lookup(const char *name) * Set up an input source */ void -setinput(char *source) +setinput(const char *source) { + char *cp; FLUSHTAPEBUF(); if (bflag) newtapebuf(ntrec); @@ -196,10 +197,11 @@ setinput(char *source) terminal = stdin; #ifdef RRESTORE - if (strchr(source, ':')) { + if ((cp = strchr(source, ':')) != NULL) { host = source; - source = strchr(host, ':'); - *source++ = '\0'; + /* Ok, because const strings don't have : */ + *cp++ = '\0'; + source = cp; if (rmthost(host) == 0) exit(1); } else diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index c171b63c6a3e..3e43b4e6f648 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -1,4 +1,4 @@ -/* $NetBSD: utilities.c,v 1.19 2005/02/17 15:00:33 xtraeme Exp $ */ +/* $NetBSD: utilities.c,v 1.20 2005/06/27 01:55:52 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: utilities.c,v 1.19 2005/02/17 15:00:33 xtraeme Exp $"); +__RCSID("$NetBSD: utilities.c,v 1.20 2005/06/27 01:55:52 christos Exp $"); #endif #endif /* not lint */ @@ -302,7 +302,7 @@ upperbnd(ino_t start) * report on a badly formed entry */ void -badentry(struct entry *ep, char *message) +badentry(struct entry *ep, const char *message) { fprintf(stderr, "bad entry: %s\n", message); @@ -368,7 +368,7 @@ dirlookup(const char *name) * Elicit a reply. */ int -reply(char *question) +reply(const char *question) { char c; @@ -411,7 +411,7 @@ void writemtree(const char *name, const char *type, const uid_t uid, const gid_t gid, const mode_t mode, const u_long flags) { - char *sep = ""; + const char *sep = ""; if ((name[0] != '.') || (name[1] != '/' && name[1] != '\0')) fprintf(Mtreefile, "./"); fprintf(Mtreefile, "%s type=%s uid=%d gid=%d mode=%#4.4o",