Module Name:src
Committed By: lukem
Date: Sat Apr 11 12:24:37 UTC 2009
Modified Files:
src/usr.bin/compress: compress.c zopen.c
Log Message:
Fix -Wcast-qual and -Wsign-compare issues
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/compress/compress.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/compress/zopen.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/compress/compress.c
diff -u src/usr.bin/compress/compress.c:1.24 src/usr.bin/compress/compress.c:1.25
--- src/usr.bin/compress/compress.c:1.24 Mon Jul 21 14:19:22 2008
+++ src/usr.bin/compress/compress.c Sat Apr 11 12:24:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: compress.c,v 1.24 2008/07/21 14:19:22 lukem Exp $ */
+/* $NetBSD: compress.c,v 1.25 2009/04/11 12:24:37 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = @(#)compress.c 8.2 (Berkeley) 1/7/94;
#else
-__RCSID($NetBSD: compress.c,v 1.24 2008/07/21 14:19:22 lukem Exp $);
+__RCSID($NetBSD: compress.c,v 1.25 2009/04/11 12:24:37 lukem Exp $);
#endif
#endif /* not lint */
@@ -55,12 +55,12 @@
#include string.h
#include unistd.h
-void compress(char *, char *, int);
+void compress(const char *, const char *, int);
void cwarn(const char *, ...) __attribute__((__format__(__printf__,1,2)));
void cwarnx(const char *, ...) __attribute__((__format__(__printf__,1,2)));
-void decompress(char *, char *, int);
-int permission(char *);
-void setfile(char *, struct stat *);
+void decompress(const char *, const char *, int);
+int permission(const char *);
+void setfile(const char *, struct stat *);
void usage(int);
int main(int, char *[]);
@@ -199,9 +199,9 @@
}
void
-compress(char *in, char *out, int bits)
+compress(const char *in, const char *out, int bits)
{
- int nr;
+ size_t nr;
struct stat isb, sb;
const char *error = NULL;
FILE *ifp, *ofp;
@@ -298,9 +298,9 @@
}
void
-decompress(char *in, char *out, int bits)
+decompress(const char *in, const char *out, int bits)
{
- int nr;
+ size_t nr;
struct stat sb;
FILE *ifp, *ofp;
int exists, isreg, oreg;
@@ -377,7 +377,7 @@
}
void
-setfile(char *name, struct stat *fs)
+setfile(const char *name, struct stat *fs)
{
static struct timeval tv[2];
@@ -412,7 +412,7 @@
}
int
-permission(char *fname)
+permission(const char *fname)
{
int ch, first;
Index: src/usr.bin/compress/zopen.c
diff -u src/usr.bin/compress/zopen.c:1.12 src/usr.bin/compress/zopen.c:1.13
--- src/usr.bin/compress/zopen.c:1.12 Thu Feb 21 02:50:11 2008
+++ src/usr.bin/compress/zopen.c Sat Apr 11 12:24:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: zopen.c,v 1.12 2008/02/21 02:50:11 joerg Exp $ */
+/* $NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $ */
/*-
* Copyright (c) 1985, 1986, 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = @(#)zopen.c 8.1 (Berkeley) 6/27/93;
#else
-static char rcsid[] = $NetBSD: zopen.c,v 1.12 2008/02/21 02:50:11 joerg Exp $;
+static char rcsid[] = $NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $;
#endif
#endif /* LIBC_SCCS and not lint */
@@ -247,7 +247,7 @@
zs = cookie;
count = num;
- bp = (u_char *)wbp;
+ bp = (const u_char *)wbp;
if (state == S_MIDDLE)
goto middle;
state = S_MIDDLE;
@@ -400,7 +400,7 @@
bp = buf;
bits = n_bits;
bytes_out += bits;
- if (fwrite(bp, sizeof(char), bits, fp) != bits)
+ if (fwrite(bp, sizeof(char), bits, fp) != (size_t)bits)
return (-1);
bp += bits;
bits = 0;
@@ -416,7 +416,7 @@
* discover the size increase until after it has read it.
*/
if (offset 0) {
-if (fwrite(buf, 1, n_bits, fp) != n_bits)
+if (fwrite(buf, 1, n_bits, fp) != (size_t)n_bits)
return (-1);
bytes_out += n_bits;
}
@@ -437,7 +437,7 @@
/* At EOF, write the rest of the buffer. */
if (offset 0) {
offset = (offset + 7) / 8;
- if (fwrite(buf, 1, offset, fp) != offset)
+ if (fwrite(buf, 1, offset, fp) != (size_t)offset)
return (-1);
bytes_out += offset;
}