corrections from linux gcc v11 compilation
[compress.git] / fprintf.c
index f74189c369b906be442261fbcfbe20ecc523614f..ff4f0353d1f947cd79e4bbba8690d0254efb3976 100644 (file)
--- a/fprintf.c
+++ b/fprintf.c
@@ -12,6 +12,7 @@
 */
 
 #include <stdarg.h>
+#include <stdint.h>
 #include <unistd.h>
 
 #include "fprintf.h"
@@ -19,7 +20,7 @@
 int _fdout = STDOUT_FILENO;
 int _fderr = STDERR_FILENO;
 
-inline unsigned int nextpow (unsigned int x, int base) {
+unsigned int nextpow (unsigned int x, int base) {
     unsigned int n = 0;
     while (x) {
         n++;
@@ -94,13 +95,14 @@ int fdprintf (int fd, const char *fmt, ...)
             case 'x': /* integer hexa */
                 if (!p) {
                     u = va_arg (ap, unsigned int);
-                    p = (void *)u;
                     if (sz == 0) {
                         sz = nextpow (u, 16);
                     }
+                } else {
+                    u = (uintptr_t)p;
                 }
                 for (i = sz, t = 1; i > 0; i--) {
-                    char x = (char)(((uintptr_t)p >> (i * 4 - 4)) & 0xf);
+                    char x = (char)((u >> (i * 4 - 4)) & 0xf);
                     if ((t == 1) && (x == 0)) {
                         *str++ = w;
                     } else {
@@ -124,8 +126,7 @@ int fdprintf (int fd, const char *fmt, ...)
     /* output string */
     int n = str - buffer;
     if (n < (int)sizeof (buffer) - 1) {
-        write (fd, buffer, n);
-        return n;
+        return write (fd, buffer, n);
     }
     return 0;
 }