commit f53caf73d4bd45dc4a5600c986a14af6d6bae337
Author: Jessica Clarke <jrtc27@jrtc27.com>
AuthorDate: Thu Jul 29 19:43:22 2021 +0100
Commit: Jessica Clarke <jrtc27@jrtc27.com>
CommitDate: Thu Jul 29 19:49:20 2021 +0100
Fix incorrect use of PRIiPTR/PRIuPTR
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.
PRIiPTR and PRIuPTR and are for (u)intptr_t arguments which, for CHERI,
are implemented as capabilities in order to preserve pointer provenance
(converting a capability to an integer is a lossy operation). However,
these arguments are of type size_t or ptrdiff_t, which remain plain
integers. Thus, use the correct C99 format strings for these.
---
src/doom/r_plane.c | 6 +++---
src/heretic/r_plane.c | 6 +++---
src/hexen/r_plane.c | 6 +++---
src/i_system.c | 2 +-
src/m_misc.c | 2 +-
src/strife/r_plane.c | 6 +++---
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/doom/r_plane.c b/src/doom/r_plane.c
index 2a7f7bd0..b63b20fd 100644
--- a/src/doom/r_plane.c
+++ b/src/doom/r_plane.c
@@ -371,15 +371,15 @@ void R_DrawPlanes (void)
#ifdef RANGECHECK
if (ds_p - drawsegs > MAXDRAWSEGS)
- I_Error ("R_DrawPlanes: drawsegs overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: drawsegs overflow (%td)",
ds_p - drawsegs);
if (lastvisplane - visplanes > MAXVISPLANES)
- I_Error ("R_DrawPlanes: visplane overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: visplane overflow (%td)",
lastvisplane - visplanes);
if (lastopening - openings > MAXOPENINGS)
- I_Error ("R_DrawPlanes: opening overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: opening overflow (%td)",
lastopening - openings);
#endif
diff --git a/src/heretic/r_plane.c b/src/heretic/r_plane.c
index 0015e978..7924c17f 100644
--- a/src/heretic/r_plane.c
+++ b/src/heretic/r_plane.c
@@ -386,13 +386,13 @@ void R_DrawPlanes(void)
#ifdef RANGECHECK
if (ds_p - drawsegs > MAXDRAWSEGS)
- I_Error("R_DrawPlanes: drawsegs overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: drawsegs overflow (%td)",
ds_p - drawsegs);
if (lastvisplane - visplanes > MAXVISPLANES)
- I_Error("R_DrawPlanes: visplane overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: visplane overflow (%td)",
lastvisplane - visplanes);
if (lastopening - openings > MAXOPENINGS)
- I_Error("R_DrawPlanes: opening overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: opening overflow (%td)",
lastopening - openings);
#endif
diff --git a/src/hexen/r_plane.c b/src/hexen/r_plane.c
index 8dd34083..3e3e014a 100644
--- a/src/hexen/r_plane.c
+++ b/src/hexen/r_plane.c
@@ -390,17 +390,17 @@ void R_DrawPlanes(void)
#ifdef RANGECHECK
if (ds_p - drawsegs > MAXDRAWSEGS)
{
- I_Error("R_DrawPlanes: drawsegs overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: drawsegs overflow (%td)",
ds_p - drawsegs);
}
if (lastvisplane - visplanes > MAXVISPLANES)
{
- I_Error("R_DrawPlanes: visplane overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: visplane overflow (%td)",
lastvisplane - visplanes);
}
if (lastopening - openings > MAXOPENINGS)
{
- I_Error("R_DrawPlanes: opening overflow (%" PRIiPTR ")",
+ I_Error("R_DrawPlanes: opening overflow (%td)",
lastopening - openings);
}
#endif
diff --git a/src/i_system.c b/src/i_system.c
index 6a2e6969..dae2107c 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -342,7 +342,7 @@ void *I_Realloc(void *ptr, size_t size)
if (size != 0 && new_ptr == NULL)
{
- I_Error ("I_Realloc: failed on reallocation of %" PRIuPTR " bytes", size);
+ I_Error ("I_Realloc: failed on reallocation of %zu bytes", size);
}
return new_ptr;
diff --git a/src/m_misc.c b/src/m_misc.c
index f7f72e72..6aa97b6e 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -424,7 +424,7 @@ char *M_StringDuplicate(const char *orig)
if (result == NULL)
{
- I_Error("Failed to duplicate string (length %" PRIuPTR ")\n",
+ I_Error("Failed to duplicate string (length %zu)\n",
strlen(orig));
}
diff --git a/src/strife/r_plane.c b/src/strife/r_plane.c
index 97c0c5fe..5bc643cb 100644
--- a/src/strife/r_plane.c
+++ b/src/strife/r_plane.c
@@ -369,15 +369,15 @@ void R_DrawPlanes (void)
#ifdef RANGECHECK
if (ds_p - drawsegs > MAXDRAWSEGS)
- I_Error ("R_DrawPlanes: drawsegs overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: drawsegs overflow (%td)",
ds_p - drawsegs);
if (lastvisplane - visplanes > MAXVISPLANES)
- I_Error ("R_DrawPlanes: visplane overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: visplane overflow (%td)",
lastvisplane - visplanes);
if (lastopening - openings > MAXOPENINGS)
- I_Error ("R_DrawPlanes: opening overflow (%" PRIiPTR ")",
+ I_Error ("R_DrawPlanes: opening overflow (%td)",
lastopening - openings);
#endif