Skip to content

Commit

Permalink
sprinkle a little const, and now everything compiles with WARNS=3
Browse files Browse the repository at this point in the history
  • Loading branch information
christos committed Jun 26, 2005
1 parent 8730720 commit 33ff1c7
Show file tree
Hide file tree
Showing 32 changed files with 135 additions and 128 deletions.
4 changes: 2 additions & 2 deletions bin/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# $NetBSD: Makefile.inc,v 1.14 2002/09/27 21:04:46 thorpej Exp $
# $NetBSD: Makefile.inc,v 1.15 2005/06/26 19:10:48 christos Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93

.include <bsd.own.mk> # for MKDYNAMICROOT definition

WARNS?= 2
WARNS?= 3
BINDIR?= /bin

.if (${MKDYNAMICROOT} == "no")
Expand Down
7 changes: 4 additions & 3 deletions bin/cp/cp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: cp.c,v 1.35 2003/09/14 19:20:18 jschauma Exp $ */
/* $NetBSD: cp.c,v 1.36 2005/06/26 19:10:48 christos Exp $ */

/*
* Copyright (c) 1988, 1993, 1994
Expand Down Expand Up @@ -43,7 +43,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95";
#else
__RCSID("$NetBSD: cp.c,v 1.35 2003/09/14 19:20:18 jschauma Exp $");
__RCSID("$NetBSD: cp.c,v 1.36 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -81,7 +81,8 @@ __RCSID("$NetBSD: cp.c,v 1.35 2003/09/14 19:20:18 jschauma Exp $");
*--(p).p_end = '\0'; \
}

PATH_T to = { to.p_path, "" };
static char empty[] = "";
PATH_T to = { to.p_path, empty };

uid_t myuid;
int Rflag, fflag, iflag, pflag, rflag, vflag;
Expand Down
4 changes: 2 additions & 2 deletions bin/cp/extern.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.9 2003/09/14 19:20:18 jschauma Exp $ */
/* $NetBSD: extern.h,v 1.10 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1991, 1993, 1994
Expand Down Expand Up @@ -36,7 +36,7 @@

typedef struct {
char *p_end; /* pointer to NULL at end of path */
char *target_end; /* pointer to end of target base */
char *target_end; /* pointer to end of target base */
char p_path[MAXPATHLEN + 1]; /* pointer to the start of a path */
} PATH_T;

Expand Down
8 changes: 4 additions & 4 deletions bin/csh/csh.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: csh.c,v 1.35 2004/08/19 22:31:38 christos Exp $ */
/* $NetBSD: csh.c,v 1.36 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#else
__RCSID("$NetBSD: csh.c,v 1.35 2004/08/19 22:31:38 christos Exp $");
__RCSID("$NetBSD: csh.c,v 1.36 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -98,7 +98,7 @@ static fpos_t seekf(void *, fpos_t, int);
static int writef(void *, const char *, int);
static int closef(void *);
static int srccat(Char *, Char *);
static int srcfile(char *, bool, bool);
static int srcfile(const char *, bool, bool);
static void phup(int);
static void srcunit(int, bool, bool);
static void mailchk(void);
Expand Down Expand Up @@ -645,7 +645,7 @@ srccat(Char *cp, Char *dp)
* Source to a file putting the file descriptor in a safe place (> 2).
*/
static int
srcfile(char *f, bool onlyown, bool flag)
srcfile(const char *f, bool onlyown, bool flag)
{
int unit;

Expand Down
8 changes: 4 additions & 4 deletions bin/csh/csh.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: csh.h,v 1.15 2003/08/07 09:05:04 agc Exp $ */
/* $NetBSD: csh.h,v 1.16 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -357,7 +357,7 @@ struct command {
*/

extern struct biltins {
char *bname;
const char *bname;
void (*bfunct)(Char **, struct command *);
short minargs, maxargs;
} bfunc[];
Expand All @@ -366,7 +366,7 @@ extern int nbfunc;
extern int nsrchn;

extern struct srch {
char *s_name;
const char *s_name;
short s_value;
} srchn[];

Expand Down Expand Up @@ -523,7 +523,7 @@ Char HISTSUB; /* auto-substitute character */
/*
* setname is a macro to save space (see sh.err.c)
*/
char *bname;
const char *bname;

#define setname(a) (bname = (a))

Expand Down
8 changes: 4 additions & 4 deletions bin/csh/dir.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.23 2004/05/10 19:11:31 christos Exp $ */
/* $NetBSD: dir.c,v 1.24 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: dir.c,v 1.23 2004/05/10 19:11:31 christos Exp $");
__RCSID("$NetBSD: dir.c,v 1.24 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand All @@ -57,7 +57,7 @@ static struct directory *dfind(Char *);
static Char *dfollow(Char *);
static void printdirs(void);
static Char *dgoto(Char *);
static void skipargs(Char ***, char *);
static void skipargs(Char ***, const char *);
static void dnewcwd(struct directory *);
static void dset(Char *);

Expand Down Expand Up @@ -157,7 +157,7 @@ dset(Char *dp)
#define DIR_LINE 4

static void
skipargs(Char ***v, char *str)
skipargs(Char ***v, const char *str)
{
Char **n, *s;

Expand Down
6 changes: 3 additions & 3 deletions bin/csh/extern.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.16 2005/02/17 16:07:53 xtraeme Exp $ */
/* $NetBSD: extern.h,v 1.17 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -193,7 +193,7 @@ void unreadc(int);
/*
* misc.c
*/
int any(char *, int);
int any(const char *, int);
Char **blkcat(Char **, Char **);
Char **blkcpy(Char **, Char **);
Char **blkend(Char **);
Expand All @@ -213,7 +213,7 @@ int prefix(Char *, Char *);
Char **saveblk(Char **);
Char *strip(Char *);
Char *quote(Char *);
char *strsave(char *);
char *strsave(const char *);
char *strspl(char *, char *);
void udvar(Char *) __attribute__((noreturn));

Expand Down
8 changes: 4 additions & 4 deletions bin/csh/func.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.29 2004/05/13 15:25:58 christos Exp $ */
/* $NetBSD: func.c,v 1.30 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)func.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: func.c,v 1.29 2004/05/13 15:25:58 christos Exp $");
__RCSID("$NetBSD: func.c,v 1.30 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -1110,7 +1110,7 @@ static const struct limits {

static const struct limits *findlim(Char *);
static RLIM_TYPE getval(const struct limits *, Char **);
static void limtail(Char *, char *);
static void limtail(Char *, const char *);
static void plim(const struct limits *, Char);
static int setlim(const struct limits *, Char, RLIM_TYPE);

Expand Down Expand Up @@ -1232,7 +1232,7 @@ getval(const struct limits *lp, Char **v)
}

static void
limtail(Char *cp, char *str)
limtail(Char *cp, const char *str)
{
while (*cp && *cp == *str)
cp++, str++;
Expand Down
17 changes: 9 additions & 8 deletions bin/csh/misc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.16 2004/01/06 00:20:16 christos Exp $ */
/* $NetBSD: misc.c,v 1.17 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: misc.c,v 1.16 2004/01/06 00:20:16 christos Exp $");
__RCSID("$NetBSD: misc.c,v 1.17 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand All @@ -52,7 +52,7 @@ __RCSID("$NetBSD: misc.c,v 1.16 2004/01/06 00:20:16 christos Exp $");
static int renum(int, int);

int
any(char *s, int c)
any(const char *s, int c)
{
if (!s)
return (0); /* Check for nil pointer */
Expand All @@ -63,18 +63,19 @@ any(char *s, int c)
}

char *
strsave(char *s)
strsave(const char *s)
{
char *n, *p;
const char *n;
char *p, *r;

if (s == NULL)
s = "";
for (p = s; *p++;)
for (n = s; *n++;)
continue;
n = p = (char *)xmalloc((size_t)((p - s) * sizeof(char)));
r = p = (char *)xmalloc((size_t)((n - s) * sizeof(char)));
while ((*p++ = *s++) != '\0')
continue;
return (n);
return (r);
}

Char **
Expand Down
6 changes: 3 additions & 3 deletions bin/csh/proc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: proc.c,v 1.28 2003/09/19 05:31:11 itojun Exp $ */
/* $NetBSD: proc.c,v 1.29 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: proc.c,v 1.28 2003/09/19 05:31:11 itojun Exp $");
__RCSID("$NetBSD: proc.c,v 1.29 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -640,7 +640,7 @@ pprint(struct process *pp, bool flag)
{
static struct rusage zru;
struct process *tp;
char *format;
const char *format;
int jobflags, pstatus, reason, status;
bool hadnl;

Expand Down
6 changes: 3 additions & 3 deletions bin/csh/time.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: time.c,v 1.14 2003/08/07 09:05:07 agc Exp $ */
/* $NetBSD: time.c,v 1.15 2005/06/26 19:10:48 christos Exp $ */

/*-
* Copyright (c) 1980, 1991, 1993
Expand Down Expand Up @@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: time.c,v 1.14 2003/08/07 09:05:07 agc Exp $");
__RCSID("$NetBSD: time.c,v 1.15 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -128,7 +128,7 @@ prusage(struct rusage *r0, struct rusage *r1, struct timeval *e,
struct timeval *b)
{
struct varent *vp;
char *cp;
const char *cp;
long i;
time_t t;
int ms;
Expand Down
7 changes: 4 additions & 3 deletions bin/date/date.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: date.c,v 1.39 2005/05/15 18:39:39 dsl Exp $ */
/* $NetBSD: date.c,v 1.40 2005/06/26 19:10:48 christos Exp $ */

/*
* Copyright (c) 1985, 1987, 1988, 1993
Expand Down Expand Up @@ -40,7 +40,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: date.c,v 1.39 2005/05/15 18:39:39 dsl Exp $");
__RCSID("$NetBSD: date.c,v 1.40 2005/06/26 19:10:48 christos Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -75,7 +75,8 @@ static void usage(void);
int
main(int argc, char *argv[])
{
char buf[1024], *format;
char buf[1024];
const char *format;
int ch;

setprogname(argv[0]);
Expand Down
4 changes: 1 addition & 3 deletions bin/dd/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.10 2002/11/29 13:11:10 lukem Exp $
# $NetBSD: Makefile,v 1.11 2005/06/26 19:10:49 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93

PROG= dd
Expand All @@ -10,6 +10,4 @@ CPPFLAGS+= -DNO_CONV
SRCS+= conv_tab.c
.endif

WARNS=2

.include <bsd.prog.mk>
10 changes: 5 additions & 5 deletions bin/df/df.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: df.c,v 1.67 2004/12/31 09:54:28 augustss Exp $ */
/* $NetBSD: df.c,v 1.68 2005/06/26 19:10:49 christos Exp $ */

/*
* Copyright (c) 1980, 1990, 1993, 1994
Expand Down Expand Up @@ -45,7 +45,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: df.c,v 1.67 2004/12/31 09:54:28 augustss Exp $");
__RCSID("$NetBSD: df.c,v 1.68 2005/06/26 19:10:49 christos Exp $");
#endif
#endif /* not lint */

Expand All @@ -72,7 +72,7 @@ int selected(const char *);
void maketypelist(char *);
long regetmntinfo(struct statvfs **, long);
void usage(void);
void prthumanval(int64_t, char *);
void prthumanval(int64_t, const char *);
void prthuman(struct statvfs *, int64_t, int64_t);
const char *
strpct64(uint64_t, uint64_t, u_int);
Expand Down Expand Up @@ -294,7 +294,7 @@ regetmntinfo(struct statvfs **mntbufp, long mntsize)
}

void
prthumanval(int64_t bytes, char *pad)
prthumanval(int64_t bytes, const char *pad)
{
char buf[6];

Expand Down Expand Up @@ -331,7 +331,7 @@ prtstat(struct statvfs *sfsp, int maxwidth)
{
static long blocksize;
static int headerlen, timesthrough;
static char *header;
static const char *header;
static const char full[] = "100%";
static const char empty[] = " 0%";
int64_t used, availblks, inodes;
Expand Down
Loading

0 comments on commit 33ff1c7

Please sign in to comment.