comparison tools/gfxconv.c @ 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 68efae89c034
children b7cd5dd0b82e
comparison
equal deleted inserted replaced
2388:2dbbc1c91231 2389:647671a9a0b8
403 if (opt == NULL) 403 if (opt == NULL)
404 goto error; 404 goto error;
405 405
406 if ((end = split = strchr(opt, ':')) == NULL) 406 if ((end = split = strchr(opt, ':')) == NULL)
407 { 407 {
408 dmErrorMsg("Invalid %s value '%s', expected <(#|%)RRGGBB|[$|0x]index>:<[$|0x]index>.\n", msg, opt); 408 dmErrorMsg("Invalid %s value '%s', expected <(#|%%)RRGGBB|[$|0x]index>:<[$|0x]index>.\n",
409 msg, opt);
409 goto error; 410 goto error;
410 } 411 }
411 412
412 // Trim whitespace 413 // Trim whitespace
413 *end = 0; 414 *end = 0;
550 int res = DMERR_OK; 551 int res = DMERR_OK;
551 552
552 if ((fp = fopen(filename, "r")) == NULL) 553 if ((fp = fopen(filename, "r")) == NULL)
553 { 554 {
554 res = dmGetErrno(); 555 res = dmGetErrno();
555 dmError(res, "Could not open color remap file '%s' for reading: %s.\n", 556 return dmError(res, "Could not open color remap file '%s' for reading: %s.\n",
556 dmErrorStr(res)); 557 filename, dmErrorStr(res));
557 return res;
558 } 558 }
559 559
560 while (fgets(line, sizeof(line), fp)) 560 while (fgets(line, sizeof(line), fp))
561 { 561 {
562 char *start = line; 562 char *start = line;
1311 { 1311 {
1312 dmMsg(1, "Downconverting FLI to multicolor.\n"); 1312 dmMsg(1, "Downconverting FLI to multicolor.\n");
1313 } 1313 }
1314 1314
1315 // Do per opcode copies 1315 // Do per opcode copies
1316 for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++) 1316 for (int opn = 0; opn < D64_MAX_ENCDEC_OPS; opn++)
1317 { 1317 {
1318 const DMC64EncDecOp *op = fmtGetEncDecOp(dstFmt, i); 1318 const DMC64EncDecOp *op = fmtGetEncDecOp(dstFmt, opn);
1319 size_t size; 1319 size_t size;
1320 1320
1321 if (op->type == DO_LAST) 1321 if (op->type == DO_LAST)
1322 break; 1322 break;
1323 1323
1338 break; 1338 break;
1339 1339
1340 if (srcBlk != NULL && srcBlk->data != NULL && srcBlk->size >= size) 1340 if (srcBlk != NULL && srcBlk->data != NULL && srcBlk->size >= size)
1341 { 1341 {
1342 // The block exists in source and is of sufficient size, so copy it 1342 // The block exists in source and is of sufficient size, so copy it
1343 dmMsg(3, "Copying whole block '%s' op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n", 1343 dmMsg(3, "Copying whole block '%s' "
1344 blkname, i, op->offs, op->offs, op->bank, size, size); 1344 "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
1345 blkname, opn, op->offs, op->offs, op->bank, size, size);
1345 1346
1346 dmC64MemBlockCopy(dstBlk, srcBlk); 1347 dmC64MemBlockCopy(dstBlk, srcBlk);
1347 } 1348 }
1348 else 1349 else
1349 switch (op->subject) 1350 switch (op->subject)
1355 case DS_EXTRA_DATA: 1356 case DS_EXTRA_DATA:
1356 if ((dmC64MemBlockAlloc(dstBlk, size)) != DMERR_OK) 1357 if ((dmC64MemBlockAlloc(dstBlk, size)) != DMERR_OK)
1357 { 1358 {
1358 return dmError(DMERR_MALLOC, 1359 return dmError(DMERR_MALLOC,
1359 "Could not allocate '%s' block! " 1360 "Could not allocate '%s' block! "
1360 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n", 1361 "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
1361 blkname, i, op->offs, op->offs, op->bank, size, size); 1362 blkname, opn, op->offs, op->offs, op->bank, size, size);
1362 } 1363 }
1363 if (srcBlk == NULL || srcBlk->data == NULL) 1364 if (srcBlk == NULL || srcBlk->data == NULL)
1364 { 1365 {
1365 dmMsg(3, "Creating whole block '%s' op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n", 1366 dmMsg(3, "Creating whole block '%s' "
1366 blkname, i, op->offs, op->offs, op->bank, size, size); 1367 "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
1368 blkname, opn, op->offs, op->offs, op->bank, size, size);
1367 } 1369 }
1368 else 1370 else
1369 { 1371 {
1370 dmMsg(3, "Creating block '%s' from partial data op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x)\n", 1372 dmMsg(3, "Creating block '%s' from partial data "
1371 blkname, i, op->offs, op->offs, op->bank, size, size); 1373 "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
1374 blkname, opn, op->offs, op->offs, op->bank, size, size);
1372 } 1375 }
1373 switch (op->type) 1376 switch (op->type)
1374 { 1377 {
1375 case DO_COPY: 1378 case DO_COPY:
1376 // If some data exists, copy it. Rest is zero. 1379 // If some data exists, copy it. Rest is zero.
1387 dmMemset(dstBlk->data, op->offs, size); 1390 dmMemset(dstBlk->data, op->offs, size);
1388 break; 1391 break;
1389 1392
1390 default: 1393 default:
1391 return dmError(DMERR_INTERNAL, 1394 return dmError(DMERR_INTERNAL,
1392 "Unhandled op type %d in " 1395 "Unhandled op type #%d in "
1393 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", 1396 "op #%d, offs=%d ($%04x), bank=%d, size=%" DM_PRIu_SIZE_T " ($%04" DM_PRIx_SIZE_T ")\n",
1394 op->type, i, op->offs, op->offs, op->bank, size, size); 1397 op->type, opn, op->offs, op->offs, op->bank, size, size);
1395 } 1398 }
1396 break; 1399 break;
1397 } 1400 }
1398 break; 1401 break;
1399 } 1402 }