changeset 2389:647671a9a0b8

More printf() format specifier size_t -related fixes.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 20:14:58 +0200
parents 2dbbc1c91231
children 88be5cf55caf
files tests/dzlibtest.c tools/fanalyze.c tools/gfxconv.c tools/lib64fmts.c tools/mod2wav.c
diffstat 5 files changed, 30 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/tests/dzlibtest.c	Thu Jan 09 20:11:41 2020 +0200
+++ b/tests/dzlibtest.c	Thu Jan 09 20:14:58 2020 +0200
@@ -317,7 +317,8 @@
     else
         ret = dmTestDMZlib(inFile, outFile, &inSize, &outSize, optCompress, optCompressLevel);
 
-    dmMsg(0, "[%d] In %d, out %d bytes.\n", ret, inSize, outSize);
+    dmMsg(0, "[%d] In %" DM_PRIu_SIZE_T ", out %" DM_PRIu_SIZE_T " bytes.\n",
+        ret, inSize, outSize);
 
 out:
     // Cleanup
--- a/tools/fanalyze.c	Thu Jan 09 20:11:41 2020 +0200
+++ b/tools/fanalyze.c	Thu Jan 09 20:14:58 2020 +0200
@@ -718,7 +718,7 @@
 
                     if (match)
                     {
-                        dmPrint(0, "%08x : ", offs);
+                        dmPrint(0, "%08" DM_PRIx_SIZE_T " : ", offs);
                         dmPrintGrepValueList(node, TRUE, file, offs);
                     }
                 }
@@ -795,7 +795,8 @@
     {
         // Allocate comparision buffer
         // XXX: integer overflow?
-        dmPrint(2, "Allocating %d element (%d bytes) comparision buffer.\n",
+        dmPrint(2, "Allocating %" DM_PRIu_SIZE_T " element (%" DM_PRIu_SIZE_T
+            " bytes) comparision buffer.\n",
             compBufSize, compBufSize * sizeof(DMCompElem));
 
         if ((compBuf = dmCalloc(compBufSize, sizeof(DMCompElem))) == NULL)
--- a/tools/gfxconv.c	Thu Jan 09 20:11:41 2020 +0200
+++ b/tools/gfxconv.c	Thu Jan 09 20:14:58 2020 +0200
@@ -405,7 +405,8 @@
 
     if ((end = split = strchr(opt, ':')) == NULL)
     {
-        dmErrorMsg("Invalid %s value '%s', expected <(#|%)RRGGBB|[$|0x]index>:<[$|0x]index>.\n", msg, opt);
+        dmErrorMsg("Invalid %s value '%s', expected <(#|%%)RRGGBB|[$|0x]index>:<[$|0x]index>.\n",
+            msg, opt);
         goto error;
     }
 
@@ -552,9 +553,8 @@
     if ((fp = fopen(filename, "r")) == NULL)
     {
         res = dmGetErrno();
-        dmError(res, "Could not open color remap file '%s' for reading: %s.\n",
-            dmErrorStr(res));
-        return res;
+        return dmError(res, "Could not open color remap file '%s' for reading: %s.\n",
+            filename, dmErrorStr(res));
     }
 
     while (fgets(line, sizeof(line), fp))
@@ -1313,9 +1313,9 @@
     }
 
     // Do per opcode copies
-    for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++)
+    for (int opn = 0; opn < D64_MAX_ENCDEC_OPS; opn++)
     {
-        const DMC64EncDecOp *op = fmtGetEncDecOp(dstFmt, i);
+        const DMC64EncDecOp *op = fmtGetEncDecOp(dstFmt, opn);
         size_t size;
 
         if (op->type == DO_LAST)
@@ -1340,8 +1340,9 @@
                 if (srcBlk != NULL && srcBlk->data != NULL && srcBlk->size >= size)
                 {
                     // The block exists in source and is of sufficient size, so copy it
-                    dmMsg(3, "Copying whole block '%s' op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n",
-                        blkname, i, op->offs, op->offs, op->bank, size, size);
+                    dmMsg(3, "Copying whole block '%s' "
+                        "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
+                        blkname, opn, op->offs, op->offs, op->bank, size, size);
 
                     dmC64MemBlockCopy(dstBlk, srcBlk);
                 }
@@ -1357,18 +1358,20 @@
                         {
                             return dmError(DMERR_MALLOC,
                                 "Could not allocate '%s' block! "
-                                "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n",
-                                blkname, i, op->offs, op->offs, op->bank, size, size);
+                                "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
+                                blkname, opn, op->offs, op->offs, op->bank, size, size);
                         }
                         if (srcBlk == NULL || srcBlk->data == NULL)
                         {
-                            dmMsg(3, "Creating whole block '%s' op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n",
-                                blkname, i, op->offs, op->offs, op->bank, size, size);
+                            dmMsg(3, "Creating whole block '%s' "
+                                "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
+                                blkname, opn, op->offs, op->offs, op->bank, size, size);
                         }
                         else
                         {
-                            dmMsg(3, "Creating block '%s' from partial data op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n",
-                                blkname, i, op->offs, op->offs, op->bank, size, size);
+                            dmMsg(3, "Creating block '%s' from partial data "
+                                "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
+                                blkname, opn, op->offs, op->offs, op->bank, size, size);
                         }
                         switch (op->type)
                         {
@@ -1389,9 +1392,9 @@
 
                             default:
                                 return dmError(DMERR_INTERNAL,
-                                    "Unhandled op type %d in "
-                                    "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n",
-                                    op->type, i, op->offs, op->offs, op->bank, size, size);
+                                    "Unhandled op type #%d in "
+                                    "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
+                                    op->type, opn, op->offs, op->offs, op->bank, size, size);
                         }
                         break;
                 }
--- a/tools/lib64fmts.c	Thu Jan 09 20:11:41 2020 +0200
+++ b/tools/lib64fmts.c	Thu Jan 09 20:14:58 2020 +0200
@@ -1455,7 +1455,8 @@
         if (mem.len != fmtUncompSize)
         {
             res = dmError(DMERR_INVALID_DATA,
-                "%s: Unexpected uncompressed data size %d bytes (should be %d).\n",
+                "%s: Unexpected uncompressed data size %" DM_PRIu_SIZE_T
+                " bytes (should be %" DM_PRIu_SIZE_T ").\n",
                 cfg.func, mem.len, fmtUncompSize);
             goto out;
         }
@@ -1464,7 +1465,7 @@
         if ((dstBuf = dmMalloc0(dstSize)) == NULL)
         {
             res = dmError(DMERR_MALLOC,
-                "%s: Could not allocate temporary memory buffer of %d bytes.\n",
+                "%s: Could not allocate temporary memory buffer of %" DM_PRIu_SIZE_T " bytes.\n",
                 cfg.func, dstSize);
             goto out;
         }
--- a/tools/mod2wav.c	Thu Jan 09 20:11:41 2020 +0200
+++ b/tools/mod2wav.c	Thu Jan 09 20:14:58 2020 +0200
@@ -305,7 +305,7 @@
         return 5;
     }
 
-    dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%d / sample]\n",
+    dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%" DM_PRIu_SIZE_T " / sample]\n",
         optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq,
         sampSize);
 
@@ -352,7 +352,7 @@
 
     // Render audio data and output to file
     if (optUsePlayTime)
-        dmMsg(1, "Rendering module (%d seconds) ...\n", optPlayTime);
+        dmMsg(1, "Rendering module (%" DM_PRIu_SIZE_T " seconds) ...\n", optPlayTime);
     else
         dmMsg(1, "Rendering module ...\n");