]> granicus.if.org Git - file/commitdiff
more c++ casts
authorChristos Zoulas <christos@zoulas.com>
Mon, 24 Oct 2016 18:02:17 +0000 (18:02 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 24 Oct 2016 18:02:17 +0000 (18:02 +0000)
src/apprentice.c
src/cdf.c
src/compress.c
src/der.c
src/softmagic.c

index e99175f4a6594a708397b674e096e9cf9c607d41..7c8390e8a28597548026cf6716b6a5131e8498bb 100644 (file)
@@ -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;
index b054e33220d9bea34e45f0031a260db52082af02..94f216333c9e8b457faf767968efd62a2a4fb664 100644 (file)
--- 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 <assert.h>
@@ -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;
                }
index cb4a85b300040b4927e277314d7ff903870fcc02..32920c3d9d868a175da2fefc50d46b046836a56f 100644 (file)
@@ -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);
index c918308eb1b0d9dc934920d10eab2cc0a402259e..ee7a7aec6de432cac98d77db97d7d6c95f9d0ef3 100644 (file)
--- 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;
index 6c35438339907be618a3a290f9678697161533c2..16e38f991bd1de2949e8dfa77be5aeb925642f29 100644 (file)
@@ -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,