# HG changeset patch # User Matti Hamalainen # Date 1544463408 -7200 # Node ID 7e4087e2740dc9353a7c7a9e0b70ee10d92835f9 # Parent 9b6027d51f7611bb5a53854d6953677d06a666ac Define macros DM_MEMCMP_SIZE() and DM_MEMCMP_LEN() as helpers. diff -r 9b6027d51f76 -r 7e4087e2740d tools/lib64fmts.c --- a/tools/lib64fmts.c Mon Dec 10 19:24:45 2018 +0200 +++ b/tools/lib64fmts.c Mon Dec 10 19:36:48 2018 +0200 @@ -8,6 +8,8 @@ */ #include "lib64gfx.h" +#define DM_MEMCMP_SIZE(mptr, mcmp) memcmp((mptr), (mcmp), sizeof(mcmp)) +#define DM_MEMCMP_LEN(mptr, mcmp) memcmp((mptr), (mcmp), strlen(mcmp)) static int fmtProbeGigapaintHires(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) { @@ -35,9 +37,9 @@ static int fmtProbeMicroIllustrator(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) { if (buf->len == fmt->size && - memcmp(buf->data + 2, fmtMicroIllustratorMagicID_1, sizeof(fmtMicroIllustratorMagicID_1)) == 0 + DM_MEMCMP_SIZE(buf->data + 2, fmtMicroIllustratorMagicID_1) == 0 && - memcmp(buf->data + 9, fmtMicroIllustratorMagicID_2, sizeof(fmtMicroIllustratorMagicID_2)) == 0 + DM_MEMCMP_SIZE(buf->data + 9, fmtMicroIllustratorMagicID_2) == 0 ) return DM_PROBE_SCORE_MAX; @@ -158,7 +160,7 @@ const Uint8 *ident = buf->data + 2; if (buf->len > 22 && dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(ident, "DRAZPAINT ", 10) == 0 && + DM_MEMCMP_LEN(ident, "DRAZPAINT ") == 0 && ident[11] == '.' && ( (ident[10] == '1' && ident[12] == '4') || (ident[10] == '2' && ident[12] == '0') @@ -233,7 +235,7 @@ { if (buf->len > 22 && dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(buf->data + 2, "DRAZLACE! 1.0", 13) == 0) + DM_MEMCMP_LEN(buf->data + 2, "DRAZLACE! 1.0") == 0) return DM_PROBE_SCORE_MAX; return DM_PROBE_SCORE_FALSE; @@ -269,7 +271,7 @@ { if (buf->len > 20 && dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(buf->data + 2, fmtBDP5MagicID, strlen(fmtBDP5MagicID)) == 0) + DM_MEMCMP_LEN(buf->data + 2, fmtBDP5MagicID) == 0) return DM_PROBE_SCORE_MAX; return DM_PROBE_SCORE_FALSE; @@ -610,7 +612,7 @@ if (buf->len >= 320 && dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(buf->data + 2, magicID, sizeof(magicID)) == 0) + DM_MEMCMP_SIZE(buf->data + 2, magicID) == 0) return DM_PROBE_SCORE_MAX; return DM_PROBE_SCORE_FALSE; @@ -788,8 +790,7 @@ static int fmtProbeFunPaint2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) { if (buf->len > 30 && - dmCompareAddr16(buf, 0, fmt->addr) && - memcmp(buf->data + 2, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) == 0) + DM_MEMCMP_LEN(buf->data + 2, fmtFunPaint2MagicID) == 0) { // Unpacked variant if (fmt->size != 0 && buf->data[14 + 2] == 0)