From: Christos Zoulas Date: Mon, 24 Oct 2016 18:02:17 +0000 (+0000) Subject: more c++ casts X-Git-Tag: FILE5_29~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=274423f0e758c4d6eb62b99d9eaadaa39d1d9e46;p=file more c++ casts --- diff --git a/src/apprentice.c b/src/apprentice.c index e99175f4..7c8390e8 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.253 2016/09/13 13:14:44 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.254 2016/10/24 15:21:07 christos Exp $") #endif /* lint */ #include "magic.h" @@ -590,7 +590,7 @@ mlist_free(struct mlist *mlist) ml = mlist->next; for (ml = mlist->next; (next = ml->next) != NULL; ml = next) { if (ml->map) - apprentice_unmap(ml->map); + apprentice_unmap(CAST(struct magic_map *, ml->map)); free(ml); if (ml == mlist) break; diff --git a/src/cdf.c b/src/cdf.c index b054e332..94f21633 100644 --- a/src/cdf.c +++ b/src/cdf.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf.c,v 1.83 2016/06/20 16:08:14 christos Exp $") +FILE_RCSID("@(#)$File: cdf.c,v 1.84 2016/10/17 15:25:34 christos Exp $") #endif #include @@ -1110,7 +1110,7 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, cep->ce_namlen = rlen; np = CAST(const uint16_t *, CAST(const void *, (b + 16))); - if (CAST(const char *, np + cep->ce_namlen) > eb) { + if (RCAST(const char *, np + cep->ce_namlen) > eb) { cep->ce_namlen = 0; break; } diff --git a/src/compress.c b/src/compress.c index cb4a85b3..32920c3d 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.98 2016/06/28 16:38:26 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.99 2016/09/16 12:12:05 christos Exp $") #endif #include "magic.h" @@ -159,7 +159,7 @@ private const struct { { "\004\"M\030",4, lz4_args }, /* LZ4 */ { "\x28\xB5\x2F\xFD", 4, zstd_args }, /* zstd */ #ifdef ZLIBSUPPORT - { zlibcmp, 0, zlib_args }, /* zlib */ + { RCAST(const void *, zlibcmp), 0, zlib_args }, /* zlib */ #endif }; @@ -208,7 +208,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, continue; #ifdef ZLIBSUPPORT if (compr[i].maglen == 0) - zm = (CAST(int (*)(const unsigned char *), + zm = (RCAST(int (*)(const unsigned char *), CCAST(void *, compr[i].magic)))(buf); else #endif @@ -366,7 +366,7 @@ nocheck: return rn - n; default: n -= rv; - buf = ((char *)buf) + rv; + buf = CAST(char *, CCAST(void *, buf)) + rv; break; } while (n > 0); diff --git a/src/der.c b/src/der.c index c918308e..ee7a7aec 100644 --- a/src/der.c +++ b/src/der.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: der.c,v 1.8 2016/07/15 00:56:04 christos Exp $") +FILE_RCSID("@(#)$File: der.c,v 1.9 2016/10/24 15:19:08 christos Exp $") #endif #endif @@ -200,7 +200,7 @@ der_tag(char *buf, size_t len, uint32_t tag) static int der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len) { - const uint8_t *d = q; + const uint8_t *d = CAST(const uint8_t *, q); switch (tag) { case DER_TAG_PRINTABLE_STRING: case DER_TAG_UTF8_STRING: @@ -222,7 +222,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len) int32_t der_offs(struct magic_set *ms, struct magic *m, size_t nbytes) { - const uint8_t *b = CAST(const void *, ms->search.s); + const uint8_t *b = RCAST(const uint8_t *, ms->search.s); size_t offs = 0, len = ms->search.s_len ? ms->search.s_len : nbytes; if (gettag(b, &offs, len) == DER_BAD) @@ -253,7 +253,7 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes) int der_cmp(struct magic_set *ms, struct magic *m) { - const uint8_t *b = CAST(const void *, ms->search.s); + const uint8_t *b = RCAST(const uint8_t *, ms->search.s); const char *s = m->value.s; size_t offs = 0, len = ms->search.s_len; uint32_t tag, tlen; diff --git a/src/softmagic.c b/src/softmagic.c index 6c354383..16e38f99 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.236 2016/07/20 11:27:08 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.237 2016/10/10 20:44:15 christos Exp $") #endif /* lint */ #include "magic.h" @@ -1875,7 +1875,7 @@ magiccheck(struct magic_set *ms, struct magic *m) size_t slen = ms->search.s_len; char *copy; if (slen != 0) { - copy = malloc(slen); + copy = CAST(char *, malloc(slen)); if (copy == NULL) { file_regfree(&rx); file_error(ms, errno,