Date: Fri, 3 Aug 2001 21:37:45 -0400 From: Mike Barcroft <mike@FreeBSD.org> To: audit@FreeBSD.org Cc: Bruce Evans <bde@zeta.org.au> Subject: cmp(1) warns patch Message-ID: <20010803213745.A4390@coffee.q9media.com>
next in thread | raw e-mail | index | archive | help
I'd appreciate comments on the following patch. If there are no objections, I'd like to commit this shortly. Best regards, Mike Barcroft ---------------------------------------------------------------------- cmp.20010803.patch o Constify o Fix some compile-time warnings. o Set WARNS?=2 Index: cmp/Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- cmp/Makefile 1998/12/06 22:58:15 1.2 +++ cmp/Makefile 2001/08/04 01:02:33 @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= cmp -CFLAGS+=-Wall SRCS= cmp.c misc.c regular.c special.c +WARNS?= 2 .include <bsd.prog.mk> Index: cmp/cmp.c =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/cmp.c,v retrieving revision 1.9 diff -u -r1.9 cmp.c --- cmp/cmp.c 2000/07/25 13:01:34 1.9 +++ cmp/cmp.c 2001/08/04 01:02:33 @@ -68,7 +68,7 @@ struct stat sb1, sb2; off_t skip1, skip2; int ch, fd1, fd2, special; - char *file1, *file2; + const char *file1, *file2; while ((ch = getopt(argc, argv, "-lsxz")) != -1) switch (ch) { Index: cmp/extern.h =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/extern.h,v retrieving revision 1.2 diff -u -r1.2 extern.h --- cmp/extern.h 2000/05/15 08:30:43 1.2 +++ cmp/extern.h 2001/08/04 01:02:33 @@ -40,9 +40,10 @@ #define DIFF_EXIT 1 #define ERR_EXIT 2 /* error exit code */ -void c_regular __P((int, char *, off_t, off_t, int, char *, off_t, off_t)); -void c_special __P((int, char *, off_t, int, char *, off_t)); -void diffmsg __P((char *, char *, off_t, off_t)); -void eofmsg __P((char *)); +void c_regular __P((int, const char *, off_t, off_t, int, const char *, + off_t, off_t)); +void c_special __P((int, const char *, off_t, int, const char *, off_t)); +void diffmsg __P((const char *, const char *, off_t, off_t)); +void eofmsg __P((const char *)); extern int lflag, sflag, xflag; Index: cmp/misc.c =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/misc.c,v retrieving revision 1.2 diff -u -r1.2 misc.c --- cmp/misc.c 1998/12/06 22:58:15 1.2 +++ cmp/misc.c 2001/08/04 01:02:33 @@ -45,7 +45,7 @@ void eofmsg(file) - char *file; + const char *file; { if (!sflag) warnx("EOF on %s", file); @@ -54,11 +54,11 @@ void diffmsg(file1, file2, byte, line) - char *file1, *file2; + const char *file1, *file2; off_t byte, line; { if (!sflag) - (void)printf("%s %s differ: char %qd, line %qd\n", - file1, file2, byte, line); + (void)printf("%s %s differ: char %lld, line %lld\n", + file1, file2, (long long)byte, (long long)line); exit(DIFF_EXIT); } Index: cmp/regular.c =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/regular.c,v retrieving revision 1.10 diff -u -r1.10 regular.c --- cmp/regular.c 2000/06/20 20:28:40 1.10 +++ cmp/regular.c 2001/08/04 01:02:33 @@ -56,7 +56,7 @@ void c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2) int fd1, fd2; - char *file1, *file2; + const char *file1, *file2; off_t skip1, len1, skip2, len2; { u_char ch, *p1, *p2; @@ -81,7 +81,7 @@ off2 = ROUNDPAGE(skip2); length = MIN(len1, len2); - if (length > SIZE_T_MAX) + if (length > (off_t)SIZE_T_MAX) return (c_special(fd1, file1, skip1, fd2, file2, skip2)); if ((p1 = (u_char *)mmap(NULL, (size_t)len1 + skip1 % pagesize, @@ -101,10 +101,12 @@ if ((ch = *p1) != *p2) { if (xflag) { dfound = 1; - (void)printf("%08qx %02x %02x\n", byte - 1, ch, *p2); + (void)printf("%08llx %02x %02x\n", + (long long)(byte - 1), ch, *p2); } else if (lflag) { dfound = 1; - (void)printf("%6qd %3o %3o\n", byte, ch, *p2); + (void)printf("%6lld %3o %3o\n", (long long)byte, + ch, *p2); } else diffmsg(file1, file2, byte, line); /* NOTREACHED */ Index: cmp/special.c =================================================================== RCS file: /home/ncvs/src/usr.bin/cmp/special.c,v retrieving revision 1.4 diff -u -r1.4 special.c --- cmp/special.c 1999/04/25 22:37:57 1.4 +++ cmp/special.c 2001/08/04 01:02:33 @@ -47,7 +47,7 @@ void c_special(fd1, file1, skip1, fd2, file2, skip2) int fd1, fd2; - char *file1, *file2; + const char *file1, *file2; off_t skip1, skip2; { int ch1, ch2; @@ -76,7 +76,8 @@ if (ch1 != ch2) { if (lflag) { dfound = 1; - (void)printf("%6qd %3o %3o\n", byte, ch1, ch2); + (void)printf("%6lld %3o %3o\n", + (long long)byte, ch1, ch2); } else { diffmsg(file1, file2, byte, line); /* NOTREACHED */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010803213745.A4390>