diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ LINKS= ${BINDIR}/rcs ${BINDIR}/ci ${BIND ${BINDIR}/rcs ${BINDIR}/rcsclean ${BINDIR}/rcs ${BINDIR}/rcsdiff \ ${BINDIR}/rcs ${BINDIR}/rcsmerge ${BINDIR}/rcs ${BINDIR}/rlog CPPFLAGS+=-I${.CURDIR} -CFLAGS+=-Wall +CFLAGS+=-Wall -I${.CURDIR} CFLAGS+=-Wstrict-prototypes -Wmissing-prototypes CFLAGS+=-Wmissing-declarations CFLAGS+=-Wshadow -Wpointer-arith -Wcast-qual CFLAGS+=-Wsign-compare diff --git a/ci.c b/ci.c --- a/ci.c +++ b/ci.c @@ -909,9 +909,9 @@ checkin_keywordscan(BUF *data, RCSNUM ** buf_append(buf, start, len); /* XXX - Not binary safe. */ buf_putc(buf, '\0'); - checkin_parsekeyword(buf_get(buf), rev, date, author, state); + checkin_parsekeyword((char *)buf_get(buf), rev, date, author, state); buf_free(buf); loopend:; } if (kwstr == NULL) diff --git a/date.y b/date.y --- a/date.y +++ b/date.y @@ -13,9 +13,9 @@ */ /* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */ /* SUPPRESS 288 on yyerrlab *//* Label unused */ -#include +/* #include */ #include #include #include diff --git a/diff.c b/diff.c --- a/diff.c +++ b/diff.c @@ -426,10 +426,10 @@ files_differ(FILE *f1, FILE *f2) static void prepare(int i, FILE *fd, off_t filesize, int flags) { struct line *p; - int j, h; - size_t sz; + int h; + size_t j, sz; rewind(fd); sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25; @@ -1141,9 +1141,9 @@ asciifile(FILE *f) cnt = fread(buf, 1, sizeof(buf), f); return (memchr(buf, '\0', cnt) == NULL); } -#define begins_with(s, pre) (strncmp(s, pre, sizeof(pre)-1) == 0) +#define begins_with(s, pre) (strncmp((const char *)s, pre, sizeof(pre)-1) == 0) static char * match_function(const long *f, int pos, FILE *fp) { @@ -1160,9 +1160,9 @@ match_function(const long *f, int pos, F nc = sizeof(buf) - 1; nc = fread(buf, 1, nc, fp); if (nc > 0) { buf[nc] = '\0'; - buf[strcspn(buf, "\n")] = '\0'; + buf[strcspn((const char *)buf, "\n")] = '\0'; if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) state = " (private)"; @@ -1172,9 +1172,9 @@ match_function(const long *f, int pos, F } else if (begins_with(buf, "public:")) { if (!state) state = " (public)"; } else { - if (strlcpy(lastbuf, buf, + if (strlcpy(lastbuf, (const char *)buf, sizeof(lastbuf)) >= sizeof(lastbuf)) errx(1, "match_function: strlcpy"); lastmatchline = pos; diff --git a/diff3.c b/diff3.c --- a/diff3.c +++ b/diff3.c @@ -455,9 +455,9 @@ ed_patch_lines(struct rcs_lines *dlines, lp->l_line[lp->l_len - 1] = '\0'; /* len - 1 is NUL terminator so we use len - 2 for 'op' */ op = lp->l_line[lp->l_len - 2]; - start = (int)strtol(lp->l_line, &ep, 10); + start = (int)strtol((const char *)lp->l_line, &ep, 10); /* Restore the last byte of the buffer */ lp->l_line[lp->l_len - 1] = tmp; @@ -896,9 +896,10 @@ edit(struct diff *diff, int fdup, int j) /* regurgitate */ static int edscript(int n) { - int j, k; + int k; + size_t j; char block[BUFSIZ+1]; for (; n > 0; n--) { if (!oflag || !overlap[n]) diff --git a/rcs.c b/rcs.c --- a/rcs.c +++ b/rcs.c @@ -802,9 +802,9 @@ rcs_patch_lines(struct rcs_lines *dlines op = *(lp->l_line); /* NUL-terminate line buffer for strtol() safety. */ tmp = lp->l_line[lp->l_len - 1]; lp->l_line[lp->l_len - 1] = '\0'; - lineno = (int)strtol((lp->l_line + 1), &ep, 10); + lineno = (int)strtol((const char *)(lp->l_line + 1), &ep, 10); if (lineno > dlines->l_nblines || lineno < 0 || *ep != ' ') errx(1, "invalid line specification in RCS patch"); ep++; @@ -1050,9 +1050,9 @@ rcs_delta_stats(struct rcs_delta *rdp, i op = *(lp->l_line); /* NUL-terminate line buffer for strtol() safety. */ tmp = lp->l_line[lp->l_len - 1]; lp->l_line[lp->l_len - 1] = '\0'; - (void)strtol((lp->l_line + 1), &ep, 10); + (void)strtol((const char *)(lp->l_line + 1), &ep, 10); ep++; nbln = (int)strtol(ep, &ep, 10); /* Restore the last byte of the buffer */ lp->l_line[lp->l_len - 1] = tmp; diff --git a/rcs.h b/rcs.h --- a/rcs.h +++ b/rcs.h @@ -29,8 +29,9 @@ #include #include +#include #include "buf.h" #define RCS_DIFF_MAXARG 32 diff --git a/rcsparse.c b/rcsparse.c --- a/rcsparse.c +++ b/rcsparse.c @@ -29,8 +29,13 @@ #include "rcs.h" #include "rcsparse.h" #include "xmalloc.h" +#if !defined(_PW_NAME_LEN) +#include +#define _PW_NAME_LEN (MAXLOGNAME-1) +#endif + #define RCS_BUFSIZE 16384 #define RCS_BUFEXTSIZE 8192 /* RCS token types */ @@ -602,9 +607,9 @@ rcsparse_text(RCSFILE *rfp, struct rcs_p return (1); pdp->rp_delta->rd_tlen = pdp->rp_tlen - 1; if (pdp->rp_delta->rd_tlen == 0) { - pdp->rp_delta->rd_text = xstrdup(""); + pdp->rp_delta->rd_text = (u_char *) xstrdup(""); } else { pdp->rp_delta->rd_text = xmalloc(pdp->rp_delta->rd_tlen); memcpy(pdp->rp_delta->rd_text, pdp->rp_buf, pdp->rp_delta->rd_tlen); @@ -1219,9 +1224,9 @@ valid_login(char *login_name) /* The first character cannot be a hyphen */ if (*login_name == '-') return 0; - for (cp = login_name ; *cp ; cp++) { + for (cp = (u_char *)login_name ; *cp ; cp++) { /* We allow '$' as the last character for samba */ if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' && !(*cp == '$' && *(cp + 1) == '\0')) { return 0; @@ -1237,9 +1242,9 @@ valid_commitid(char *commitid) { unsigned char *cp; /* A-Za-z0-9 */ - for (cp = commitid; *cp ; cp++) { + for (cp = (u_char *)commitid; *cp ; cp++) { if (!isalnum(*cp)) return 0; } if ((char *)cp - commitid > RCS_COMMITID_MAXLEN) diff --git a/rlog.c b/rlog.c --- a/rlog.c +++ b/rlog.c @@ -340,9 +340,9 @@ rlog_select_daterev(RCSFILE *rcsfile, ch static void rlog_file(const char *fname, RCSFILE *file) { char numb[RCS_REV_BUFSZ]; - u_int nrev; + int nrev; struct rcs_sym *sym; struct rcs_access *acp; struct rcs_delta *rdp; struct rcs_lock *lkp; @@ -355,10 +355,14 @@ rlog_file(const char *fname, RCSFILE *fi errx(1, "invalid date: %s", rlog_dates); } else nrev = file->rf_ndelta; +#if 0 if ((workfile = basename(fname)) == NULL) err(1, "basename"); +#else + workfile = (char *)fname; +#endif /* * In case they specified 'foo,v' as argument. */ diff --git a/xmalloc.c b/xmalloc.c --- a/xmalloc.c +++ b/xmalloc.c @@ -21,8 +21,12 @@ #include #include "xmalloc.h" +#if !defined(u_long) +#define u_long unsigned long +#endif + void * xmalloc(size_t size) { void *ptr; diff --git a/xmalloc.h b/xmalloc.h --- a/xmalloc.h +++ b/xmalloc.h @@ -18,8 +18,13 @@ #ifndef XMALLOC_H #define XMALLOC_H +#if !defined(SIZE_MAX) +#include +#define SIZE_MAX OFF_MAX +#endif + void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xrealloc(void *, size_t, size_t); void xfree(void *);