ref: 993c034039fb0a32770b1bf2a74a168a02e8181b
parent: 09f16bda4a734309f2f17d63643ec0dd3a153b76
author: ISSOtm <[email protected]>
date: Fri Jan 22 03:37:40 EST 2021
Avoid using EXPAND_AND_STR with external defines There is no guarantee that they are purely numeric, use the values instead
--- a/src/asm/macro.c
+++ b/src/asm/macro.c
@@ -36,7 +36,7 @@
* guarantees the size of the buffer will be correct. I was unable to find a
* better solution, but if you have one, please feel free!
*/
-static char uniqueIDBuf[] = "_" EXPAND_AND_STR(UINT32_MAX);
+static char uniqueIDBuf[] = "_u4294967295"; // UINT32_MAX
static char *uniqueIDPtr = NULL;
struct MacroArgs *macro_GetCurrentArgs(void)
@@ -61,13 +61,12 @@
{
#define macArgs (*argPtr)
if (macArgs->nbArgs == MAXMACROARGS)
- error("A maximum of " EXPAND_AND_STR(MAXMACROARGS)
- " arguments is allowed\n");
+ error("A maximum of " EXPAND_AND_STR(MAXMACROARGS) " arguments is allowed\n");
if (macArgs->nbArgs >= macArgs->capacity) {
macArgs->capacity *= 2;
/* Check that overflow didn't roll us back */
if (macArgs->capacity <= macArgs->nbArgs)
- fatalerror("Failed to add new macro argument: possible capacity overflow\n");
+ fatalerror("Failed to add new macro argument: capacity overflow\n");
macArgs = realloc(macArgs, SIZEOF_ARGS(macArgs->capacity));
if (!macArgs)
fatalerror("Error adding new macro argument: %s\n", strerror(errno));
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -435,7 +435,7 @@
char const *fileName, uint32_t i,
struct Section *fileSections[], struct FileStackNode fileNodes[])
{
- char assertName[sizeof("Assertion #" EXPAND_AND_STR(UINT32_MAX))];
+ char assertName[sizeof("Assertion #4294967295")]; // UINT32_MAX
snprintf(assertName, sizeof(assertName), "Assertion #%" PRIu32, i);