URI:
       libc/stdio: Use uinptr_t instead of -1 pointers - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit b4bb95aaed9b85dc43d293e2c7310e81f0092005
   DIR parent 10686ff83b100fbf8f51b136fe5b351be6014226
  HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Wed,  6 May 2026 21:07:48 +0200
       
       libc/stdio: Use uinptr_t instead of -1 pointers
       
       Using (char *)-1 - s should work in the majority of systems and
       or compilers, but using uinptr_t and UINTPTR_MAX makes the code
       cleaner and allows to remove the comment.
       
       Diffstat:
         M src/libc/stdio/vsprintf.c           |      12 +++---------
       
       1 file changed, 3 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/src/libc/stdio/vsprintf.c b/src/libc/stdio/vsprintf.c
       @@ -7,13 +7,7 @@
        int
        vsprintf(char *restrict s, const char *restrict fmt, va_list va)
        {
       -        /*
       -         * we used to use SIZE_MAX here, but that is just
       -         * wrong because we build a rp pointer that in that
       -         * case it is just wp - 1 by definition. As it
       -         * is impossible to span an object further than
       -         * the end of the memory space we can use the number
       -         * of bytes until the end of the address space.
       -         */
       -        return vsnprintf(s, (char *)-1 - s, fmt, va);
       +        uintptr_t addr = (uintptr_t) s;
       +
       +        return vsnprintf(s, UINTPTR_MAX - addr, fmt, va);
        }