Sprinkle __UNCONST and fix some casts to make this pass WARNS=4
Note, that we cannot fix this properly because it will break the zlib.h API.
This commit is contained in:
parent
feedf5e952
commit
b85ba082e0
4
common/dist/zlib/compress.c
vendored
4
common/dist/zlib/compress.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compress.c,v 1.1.1.1 2006/01/14 20:10:24 christos Exp $ */
|
||||
/* $NetBSD: compress.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* compress.c -- compress a memory buffer
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
@ -31,7 +31,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
||||
stream.next_in = (Bytef*)source;
|
||||
stream.next_in = __UNCONST(source);
|
||||
stream.avail_in = (uInt)sourceLen;
|
||||
#ifdef MAXSEG_64K
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
|
4
common/dist/zlib/deflate.c
vendored
4
common/dist/zlib/deflate.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: deflate.c,v 1.2 2006/01/16 17:02:29 christos Exp $ */
|
||||
/* $NetBSD: deflate.c,v 1.3 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* deflate.c -- compress data using the deflation algorithm
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
@ -299,7 +299,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
||||
s->pending_buf == Z_NULL) {
|
||||
s->status = FINISH_STATE;
|
||||
strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
|
||||
strm->msg = __UNCONST(ERR_MSG(Z_MEM_ERROR));
|
||||
deflateEnd (strm);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
|
19
common/dist/zlib/gzio.c
vendored
19
common/dist/zlib/gzio.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gzio.c,v 1.1.1.1 2006/01/14 20:10:29 christos Exp $ */
|
||||
/* $NetBSD: gzio.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* gzio.c -- IO on .gz files
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
@ -100,7 +100,7 @@ local gzFile gz_open (path, mode, fd)
|
||||
int err;
|
||||
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
||||
int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
|
||||
char *p = (char*)mode;
|
||||
const char *p = mode;
|
||||
gz_stream *s;
|
||||
char fmode[80]; /* copy of mode, without the compression level */
|
||||
char *m = fmode;
|
||||
@ -302,7 +302,8 @@ local void check_header(s)
|
||||
if (len < 2) {
|
||||
if (len) s->inbuf[0] = s->stream.next_in[0];
|
||||
errno = 0;
|
||||
len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
|
||||
len = (uInt)fread(s->inbuf + len, 1, (size_t)(Z_BUFSIZE >> len),
|
||||
s->file);
|
||||
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
|
||||
s->stream.avail_in += len;
|
||||
s->stream.next_in = s->inbuf;
|
||||
@ -567,7 +568,7 @@ int ZEXPORT gzwrite (file, buf, len)
|
||||
|
||||
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
|
||||
|
||||
s->stream.next_in = (Bytef*)buf;
|
||||
s->stream.next_in = __UNCONST(buf);
|
||||
s->stream.avail_in = len;
|
||||
|
||||
while (s->stream.avail_in != 0) {
|
||||
@ -696,7 +697,7 @@ int ZEXPORT gzputs(file, s)
|
||||
gzFile file;
|
||||
const char *s;
|
||||
{
|
||||
return gzwrite(file, (char*)s, (unsigned)strlen(s));
|
||||
return gzwrite(file, __UNCONST(s), (unsigned)strlen(s));
|
||||
}
|
||||
|
||||
|
||||
@ -990,7 +991,7 @@ const char * ZEXPORT gzerror (file, errnum)
|
||||
gzFile file;
|
||||
int *errnum;
|
||||
{
|
||||
char *m;
|
||||
const char *m;
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
if (s == NULL) {
|
||||
@ -1000,13 +1001,13 @@ const char * ZEXPORT gzerror (file, errnum)
|
||||
*errnum = s->z_err;
|
||||
if (*errnum == Z_OK) return (const char*)"";
|
||||
|
||||
m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
|
||||
m = *errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg;
|
||||
|
||||
if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
|
||||
if (m == NULL || *m == '\0') m = ERR_MSG(s->z_err);
|
||||
|
||||
TRYFREE(s->msg);
|
||||
s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
|
||||
if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
|
||||
if (s->msg == Z_NULL) return ERR_MSG(Z_MEM_ERROR);
|
||||
strcpy(s->msg, s->path);
|
||||
strcat(s->msg, ": ");
|
||||
strcat(s->msg, m);
|
||||
|
24
common/dist/zlib/infback.c
vendored
24
common/dist/zlib/infback.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: infback.c,v 1.1.1.1 2006/01/14 20:10:29 christos Exp $ */
|
||||
/* $NetBSD: infback.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* infback.c -- inflate using a call-back interface
|
||||
* Copyright (C) 1995-2005 Mark Adler
|
||||
@ -310,7 +310,7 @@ void FAR *out_desc;
|
||||
state->mode = TABLE;
|
||||
break;
|
||||
case 3:
|
||||
strm->msg = (char *)"invalid block type";
|
||||
strm->msg = __UNCONST("invalid block type");
|
||||
state->mode = BAD;
|
||||
}
|
||||
DROPBITS(2);
|
||||
@ -321,7 +321,7 @@ void FAR *out_desc;
|
||||
BYTEBITS(); /* go to byte boundary */
|
||||
NEEDBITS(32);
|
||||
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
||||
strm->msg = (char *)"invalid stored block lengths";
|
||||
strm->msg = __UNCONST("invalid stored block lengths");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -359,7 +359,7 @@ void FAR *out_desc;
|
||||
DROPBITS(4);
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if (state->nlen > 286 || state->ndist > 30) {
|
||||
strm->msg = (char *)"too many length or distance symbols";
|
||||
strm->msg = __UNCONST("too many length or distance symbols");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -381,7 +381,7 @@ void FAR *out_desc;
|
||||
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid code lengths set";
|
||||
strm->msg = __UNCONST("invalid code lengths set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -405,7 +405,7 @@ void FAR *out_desc;
|
||||
NEEDBITS(this.bits + 2);
|
||||
DROPBITS(this.bits);
|
||||
if (state->have == 0) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = __UNCONST("invalid bit length repeat");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -428,7 +428,7 @@ void FAR *out_desc;
|
||||
DROPBITS(7);
|
||||
}
|
||||
if (state->have + copy > state->nlen + state->ndist) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = __UNCONST("invalid bit length repeat");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -447,7 +447,7 @@ void FAR *out_desc;
|
||||
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid literal/lengths set";
|
||||
strm->msg = __UNCONST("invalid literal/lengths set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -456,7 +456,7 @@ void FAR *out_desc;
|
||||
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||
&(state->next), &(state->distbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid distances set";
|
||||
strm->msg = __UNCONST("invalid distances set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -514,7 +514,7 @@ void FAR *out_desc;
|
||||
|
||||
/* invalid code */
|
||||
if (this.op & 64) {
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
strm->msg = __UNCONST("invalid literal/length code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -546,7 +546,7 @@ void FAR *out_desc;
|
||||
}
|
||||
DROPBITS(this.bits);
|
||||
if (this.op & 64) {
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
strm->msg = __UNCONST("invalid distance code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -561,7 +561,7 @@ void FAR *out_desc;
|
||||
}
|
||||
if (state->offset > state->wsize - (state->whave < state->wsize ?
|
||||
left : 0)) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
strm->msg = __UNCONST("invalid distance too far back");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
8
common/dist/zlib/inffast.c
vendored
8
common/dist/zlib/inffast.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: inffast.c,v 1.2 2006/01/14 20:26:05 christos Exp $ */
|
||||
/* $NetBSD: inffast.c,v 1.3 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* inffast.c -- fast decoding
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
@ -189,7 +189,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||
if (dist > op) { /* see if copy from window */
|
||||
op = dist - op; /* distance back in window */
|
||||
if (op > whave) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
strm->msg = __UNCONST("invalid distance too far back");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -265,7 +265,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||
goto dodist;
|
||||
}
|
||||
else {
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
strm->msg = __UNCONST("invalid distance code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -280,7 +280,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||
break;
|
||||
}
|
||||
else {
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
strm->msg = __UNCONST("invalid literal/length code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
42
common/dist/zlib/inflate.c
vendored
42
common/dist/zlib/inflate.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: inflate.c,v 1.1.1.1 2006/01/14 20:10:31 christos Exp $ */
|
||||
/* $NetBSD: inflate.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* inflate.c -- zlib decompression
|
||||
* Copyright (C) 1995-2005 Mark Adler
|
||||
@ -610,19 +610,19 @@ int flush;
|
||||
if (
|
||||
#endif
|
||||
((BITS(8) << 8) + (hold >> 8)) % 31) {
|
||||
strm->msg = (char *)"incorrect header check";
|
||||
strm->msg = __UNCONST("incorrect header check");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
if (BITS(4) != Z_DEFLATED) {
|
||||
strm->msg = (char *)"unknown compression method";
|
||||
strm->msg = __UNCONST("unknown compression method");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
DROPBITS(4);
|
||||
len = BITS(4) + 8;
|
||||
if (len > state->wbits) {
|
||||
strm->msg = (char *)"invalid window size";
|
||||
strm->msg = __UNCONST("invalid window size");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -637,12 +637,12 @@ int flush;
|
||||
NEEDBITS(16);
|
||||
state->flags = (int)(hold);
|
||||
if ((state->flags & 0xff) != Z_DEFLATED) {
|
||||
strm->msg = (char *)"unknown compression method";
|
||||
strm->msg = __UNCONST("unknown compression method");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
if (state->flags & 0xe000) {
|
||||
strm->msg = (char *)"unknown header flags set";
|
||||
strm->msg = __UNCONST("unknown header flags set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -746,7 +746,7 @@ int flush;
|
||||
if (state->flags & 0x0200) {
|
||||
NEEDBITS(16);
|
||||
if (hold != (state->check & 0xffff)) {
|
||||
strm->msg = (char *)"header crc mismatch";
|
||||
strm->msg = __UNCONST("header crc mismatch");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -801,7 +801,7 @@ int flush;
|
||||
state->mode = TABLE;
|
||||
break;
|
||||
case 3:
|
||||
strm->msg = (char *)"invalid block type";
|
||||
strm->msg = __UNCONST("invalid block type");
|
||||
state->mode = BAD;
|
||||
}
|
||||
DROPBITS(2);
|
||||
@ -810,7 +810,7 @@ int flush;
|
||||
BYTEBITS(); /* go to byte boundary */
|
||||
NEEDBITS(32);
|
||||
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
||||
strm->msg = (char *)"invalid stored block lengths";
|
||||
strm->msg = __UNCONST("invalid stored block lengths");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -846,7 +846,7 @@ int flush;
|
||||
DROPBITS(4);
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if (state->nlen > 286 || state->ndist > 30) {
|
||||
strm->msg = (char *)"too many length or distance symbols";
|
||||
strm->msg = __UNCONST("too many length or distance symbols");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -868,7 +868,7 @@ int flush;
|
||||
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid code lengths set";
|
||||
strm->msg = __UNCONST("invalid code lengths set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -892,7 +892,7 @@ int flush;
|
||||
NEEDBITS(this.bits + 2);
|
||||
DROPBITS(this.bits);
|
||||
if (state->have == 0) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = __UNCONST("invalid bit length repeat");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -915,7 +915,7 @@ int flush;
|
||||
DROPBITS(7);
|
||||
}
|
||||
if (state->have + copy > state->nlen + state->ndist) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = __UNCONST("invalid bit length repeat");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -934,7 +934,7 @@ int flush;
|
||||
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid literal/lengths set";
|
||||
strm->msg = __UNCONST("invalid literal/lengths set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -943,7 +943,7 @@ int flush;
|
||||
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||
&(state->next), &(state->distbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid distances set";
|
||||
strm->msg = __UNCONST("invalid distances set");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -986,7 +986,7 @@ int flush;
|
||||
break;
|
||||
}
|
||||
if (this.op & 64) {
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
strm->msg = __UNCONST("invalid literal/length code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ int flush;
|
||||
}
|
||||
DROPBITS(this.bits);
|
||||
if (this.op & 64) {
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
strm->msg = __UNCONST("invalid distance code");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -1033,13 +1033,13 @@ int flush;
|
||||
}
|
||||
#ifdef INFLATE_STRICT
|
||||
if (state->offset > state->dmax) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
strm->msg = __UNCONST("invalid distance too far back");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (state->offset > state->whave + out - left) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
strm->msg = __UNCONST("invalid distance too far back");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -1091,7 +1091,7 @@ int flush;
|
||||
state->flags ? hold :
|
||||
#endif
|
||||
REVERSE(hold)) != state->check) {
|
||||
strm->msg = (char *)"incorrect data check";
|
||||
strm->msg = __UNCONST("incorrect data check");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
@ -1104,7 +1104,7 @@ int flush;
|
||||
if (state->wrap && state->flags) {
|
||||
NEEDBITS(32);
|
||||
if (hold != (state->total & 0xffffffffUL)) {
|
||||
strm->msg = (char *)"incorrect length check";
|
||||
strm->msg = __UNCONST("incorrect length check");
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
5
common/dist/zlib/trees.c
vendored
5
common/dist/zlib/trees.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trees.c,v 1.2 2006/01/16 17:02:29 christos Exp $ */
|
||||
/* $NetBSD: trees.c,v 1.3 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* trees.c -- output deflated data using Huffman coding
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly
|
||||
@ -988,7 +988,8 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||
#endif
|
||||
send_bits(s, (STATIC_TREES<<1)+eof, 3);
|
||||
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
||||
compress_block(s, (ct_data *)__UNCONST(static_ltree),
|
||||
(ct_data *)__UNCONST(static_dtree));
|
||||
#ifdef ZLIB_DEBUG
|
||||
s->compressed_len += 3 + s->static_len;
|
||||
#endif
|
||||
|
4
common/dist/zlib/uncompr.c
vendored
4
common/dist/zlib/uncompr.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uncompr.c,v 1.1.1.1 2006/01/14 20:10:31 christos Exp $ */
|
||||
/* $NetBSD: uncompr.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* uncompr.c -- decompress a memory buffer
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
@ -34,7 +34,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
||||
stream.next_in = (Bytef*)source;
|
||||
stream.next_in = (Bytef*)__UNCONST(source);
|
||||
stream.avail_in = (uInt)sourceLen;
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
||||
|
4
common/dist/zlib/zutil.h
vendored
4
common/dist/zlib/zutil.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: zutil.h,v 1.3 2006/01/16 17:02:29 christos Exp $ */
|
||||
/* $NetBSD: zutil.h,v 1.4 2006/01/27 00:45:27 christos Exp $ */
|
||||
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
@ -65,7 +65,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
||||
return (strm->msg = __UNCONST(ERR_MSG(err)), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
Loading…
Reference in New Issue
Block a user