Fix WARNS=4 issues (-Wcast-qual -Wsign-compare)

This commit is contained in:
lukem 2009-04-13 07:29:55 +00:00
parent 9ad3f56728
commit d27a41bf3e
5 changed files with 25 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: compile.c,v 1.35 2007/04/17 20:30:29 christos Exp $ */
/* $NetBSD: compile.c,v 1.36 2009/04/13 07:29:55 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -76,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: compile.c,v 1.35 2007/04/17 20:30:29 christos Exp $");
__RCSID("$NetBSD: compile.c,v 1.36 2009/04/13 07:29:55 lukem Exp $");
#endif
#endif /* not lint */
@ -118,7 +118,7 @@ static char *compile_text(void);
static char *compile_tr(char *, char **);
static struct s_command
**compile_stream(struct s_command **);
static char *duptoeol(char *, char *);
static char *duptoeol(char *, const char *);
static void enterlabel(struct s_command *);
static struct s_command
*findlabel(char *);
@ -525,7 +525,7 @@ compile_subst(char *p, struct s_subst *s)
*sp++ = '\\';
ref = *p - '0';
if (s->re != NULL &&
ref > s->re->re_nsub)
(size_t)ref > s->re->re_nsub)
err(COMPILE,
"\\%c not defined in the RE", *p);
if (s->maxbref < ref)
@ -743,7 +743,7 @@ compile_addr(char *p, struct s_addr *a)
* Return a copy of all the characters up to \n or \0.
*/
static char *
duptoeol(char *s, char *ctype)
duptoeol(char *s, const char *ctype)
{
size_t len;
int ws;

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.9 2003/08/07 11:15:49 agc Exp $ */
/* $NetBSD: extern.h,v 1.10 2009/04/13 07:29:56 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)extern.h 8.1 (Berkeley) 6/6/93
* $NetBSD: extern.h,v 1.9 2003/08/07 11:15:49 agc Exp $
* $NetBSD: extern.h,v 1.10 2009/04/13 07:29:56 lukem Exp $
*/
/*-
@ -70,7 +70,7 @@
* SUCH DAMAGE.
*
* from: @(#)extern.h 8.1 (Berkeley) 6/6/93
* $NetBSD: extern.h,v 1.9 2003/08/07 11:15:49 agc Exp $
* $NetBSD: extern.h,v 1.10 2009/04/13 07:29:56 lukem Exp $
*/
extern struct s_command *prog;
@ -82,11 +82,11 @@ extern int appendnum;
extern int lastline;
extern int aflag, eflag, nflag;
extern int ere;
extern char *fname;
extern const char *fname;
void cfclose(struct s_command *, struct s_command *);
void compile(void);
void cspace(SPACE *, char *, size_t, enum e_spflag);
void cspace(SPACE *, const char *, size_t, enum e_spflag);
char *cu_fgets(char *, int);
void err(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.19 2008/09/16 13:32:04 perry Exp $ */
/* $NetBSD: main.c,v 1.20 2009/04/13 07:29:55 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/3/94";
#else
__RCSID("$NetBSD: main.c,v 1.19 2008/09/16 13:32:04 perry Exp $");
__RCSID("$NetBSD: main.c,v 1.20 2009/04/13 07:29:55 lukem Exp $");
#endif
#endif /* not lint */
@ -135,7 +135,7 @@ int aflag, eflag, nflag, ere;
* Current file and line number; line numbers restart across compilation
* units, but span across input files.
*/
char *fname; /* File name. */
const char *fname; /* File name. */
u_long linenum;
int lastline; /* TRUE on the last line of the last file */
@ -231,7 +231,7 @@ again:
case CU_STRING:
if ((snprintf(string_ident,
sizeof(string_ident), "\"%s\"", script->s)) >=
sizeof(string_ident) - 1)
(int)(sizeof(string_ident) - 1))
(void)strcpy(string_ident +
sizeof(string_ident) - 6, " ...\"");
fname = string_ident;

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.9 2006/06/18 05:16:41 gdamore Exp $ */
/* $NetBSD: misc.c,v 1.10 2009/04/13 07:29:55 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -76,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: misc.c,v 1.9 2006/06/18 05:16:41 gdamore Exp $");
__RCSID("$NetBSD: misc.c,v 1.10 2009/04/13 07:29:55 lukem Exp $");
#endif
#endif /* not lint */
@ -127,12 +127,13 @@ xrealloc(void *p, u_int size)
char *
strregerror(int errcode, regex_t *preg)
{
char buf[1];
static char *oe;
size_t s;
if (oe != NULL)
free(oe);
s = regerror(errcode, preg, "", 0);
s = regerror(errcode, preg, buf, 0);
oe = xmalloc(s);
(void)regerror(errcode, preg, oe, s);
return (oe);

View File

@ -1,4 +1,4 @@
/* $NetBSD: process.c,v 1.37 2006/06/18 05:16:41 gdamore Exp $ */
/* $NetBSD: process.c,v 1.38 2009/04/13 07:29:55 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -76,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)process.c 8.6 (Berkeley) 4/20/94";
#else
__RCSID("$NetBSD: process.c,v 1.37 2006/06/18 05:16:41 gdamore Exp $");
__RCSID("$NetBSD: process.c,v 1.38 2009/04/13 07:29:55 lukem Exp $");
#endif
#endif /* not lint */
@ -272,7 +272,7 @@ redirect:
DEFFILEMODE)) == -1)
err(FATAL, "%s: %s",
cp->t, strerror(errno));
if (write(cp->u.fd, ps, psl) != psl)
if ((size_t)write(cp->u.fd, ps, psl) != psl)
err(FATAL, "%s: %s",
cp->t, strerror(errno));
break;
@ -369,7 +369,7 @@ substitute(struct s_command *cp)
s = ps;
re = cp->u.s->re;
if (re == NULL) {
if (defpreg != NULL && cp->u.s->maxbref > defpreg->re_nsub) {
if (defpreg != NULL && (size_t)cp->u.s->maxbref > defpreg->re_nsub) {
linenum = cp->u.s->linenum;
err(COMPILE, "\\%d not defined in the RE",
cp->u.s->maxbref);
@ -456,7 +456,7 @@ substitute(struct s_command *cp)
if (cp->u.s->wfd == -1 && (cp->u.s->wfd = open(cp->u.s->wfile,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1)
err(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno));
if (write(cp->u.s->wfd, ps, psl) != psl)
if ((size_t)write(cp->u.s->wfd, ps, psl) != psl)
err(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno));
}
return (1);
@ -505,7 +505,7 @@ static void
lputs(char *s)
{
int count;
char *escapes, *p;
const char *escapes, *p;
#ifndef HAVE_NBTOOL_CONFIG_H
struct winsize win;
#endif
@ -642,7 +642,7 @@ regsub(SPACE *sp, char *string, char *src)
* space as necessary.
*/
void
cspace(SPACE *sp, char *p, size_t len, enum e_spflag spflag)
cspace(SPACE *sp, const char *p, size_t len, enum e_spflag spflag)
{
size_t tlen;