shithub: choc

Download patch

ref: f53caf73d4bd45dc4a5600c986a14af6d6bae337
parent: 376368b46b9d5f454b8f0075bfb2e843367ca618
author: Jessica Clarke <jrtc27@jrtc27.com>
date: Thu Jul 29 15:43:22 EDT 2021

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.

--- a/src/doom/r_plane.c
+++ b/src/doom/r_plane.c
@@ -371,15 +371,15 @@
 				
 #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
 
--- a/src/heretic/r_plane.c
+++ b/src/heretic/r_plane.c
@@ -386,13 +386,13 @@
 
 #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
 
--- a/src/hexen/r_plane.c
+++ b/src/hexen/r_plane.c
@@ -390,17 +390,17 @@
 #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
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -342,7 +342,7 @@
 
     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;
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -424,7 +424,7 @@
 
     if (result == NULL)
     {
-        I_Error("Failed to duplicate string (length %" PRIuPTR ")\n",
+        I_Error("Failed to duplicate string (length %zu)\n",
                 strlen(orig));
     }
 
--- a/src/strife/r_plane.c
+++ b/src/strife/r_plane.c
@@ -369,15 +369,15 @@
 				
 #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