This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 22321caab17dd676a81f7e2f45dc676d783e8d6f
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 20 17:11:22 2026 +0200

    netutils/thttpd: Print size_t and ssize_t values with %zu and %zd.
    
    Some debug messages print size_t and ssize_t values with %d.  On a
    64-bit target these types are wider than int, so the format check
    fails, and with -Werror the build stops.  The check is done also when
    the debug output is off.
    
    Use %zu for size_t and %zd for ssize_t.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 netutils/thttpd/thttpd_alloc.c | 10 +++++-----
 netutils/thttpd/thttpd_cgi.c   | 12 ++++++------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/netutils/thttpd/thttpd_alloc.c b/netutils/thttpd/thttpd_alloc.c
index b6fc9d7e5..92c107a39 100644
--- a/netutils/thttpd/thttpd_alloc.c
+++ b/netutils/thttpd/thttpd_alloc.c
@@ -83,11 +83,11 @@ FAR void *httpd_malloc(size_t nbytes)
 
   if (!ptr)
     {
-      nerr("ERROR: Allocation of %d bytes failed\n", nbytes);
+      nerr("ERROR: Allocation of %zu bytes failed\n", nbytes);
     }
   else
     {
-      ninfo("Allocated %d bytes at %p\n", nbytes, ptr);
+      ninfo("Allocated %zu bytes at %p\n", nbytes, ptr);
       g_nallocations++;
       g_allocated += nbytes;
     }
@@ -104,12 +104,12 @@ FAR void *httpd_realloc(FAR void *oldptr, size_t oldsize, 
size_t newsize)
 
   if (!ptr)
     {
-      nerr("ERROR: Re-allocation from %d to %d bytes failed\n",
+      nerr("ERROR: Re-allocation from %zu to %zu bytes failed\n",
            oldsize, newsize);
     }
   else
     {
-      ninfo("Re-allocated form %d to %d bytes (from %p to %p)\n",
+      ninfo("Re-allocated form %zu to %zu bytes (from %p to %p)\n",
             oldsize, newsize, oldptr, ptr);
       g_allocated += (newsize - oldsize);
     }
@@ -175,7 +175,7 @@ void httpd_realloc_str(char **pstr, size_t *maxsize, size_t 
size)
 
   if (!*pstr)
     {
-      nerr("ERROR: out of memory reallocating a string to %d bytes\n",
+      nerr("ERROR: out of memory reallocating a string to %zu bytes\n",
            *maxsize);
       exit(1);
     }
diff --git a/netutils/thttpd/thttpd_cgi.c b/netutils/thttpd/thttpd_cgi.c
index 665c5b228..bad344809 100644
--- a/netutils/thttpd/thttpd_cgi.c
+++ b/netutils/thttpd/thttpd_cgi.c
@@ -379,7 +379,7 @@ static inline int cgi_interpose_input(struct cgi_conn_s *cc)
           nbytes_read = read(cc->connfd, cc->inbuf.buffer,
                              MIN(CONFIG_THTTPD_CGIINBUFFERSIZE,
                              cc->inbuf.contentlength - cc->inbuf.nbytes));
-          ninfo("nbytes_read: %d\n", nbytes_read);
+          ninfo("nbytes_read: %zd\n", nbytes_read);
           if (nbytes_read < 0)
             {
               if (errno != EINTR)
@@ -395,7 +395,7 @@ static inline int cgi_interpose_input(struct cgi_conn_s *cc)
         {
           nbytes_written = httpd_write(cc->wrfd, cc->inbuf.buffer,
                                        nbytes_read);
-          ninfo("nbytes_written: %d\n", nbytes_written);
+          ninfo("nbytes_written: %zd\n", nbytes_written);
           if (nbytes_written != nbytes_read)
             {
               nerr("ERROR: httpd_write failed\n");
@@ -472,7 +472,7 @@ static inline int cgi_interpose_output(struct cgi_conn_s 
*cc)
 
               nbytes_read = read(cc->rdfd, cc->inbuf.buffer,
                                  CONFIG_THTTPD_CGIINBUFFERSIZE);
-              ninfo("Read %d bytes from fd %d\n", nbytes_read, cc->rdfd);
+              ninfo("Read %zd bytes from fd %d\n", nbytes_read, cc->rdfd);
 
               if (nbytes_read < 0)
                 {
@@ -512,7 +512,7 @@ static inline int cgi_interpose_output(struct cgi_conn_s 
*cc)
                        nbytes_read);
               cc->outbuf.len                   += nbytes_read;
               cc->outbuf.buffer[cc->outbuf.len] = '\0';
-              ninfo("Header bytes accumulated: %d\n", cc->outbuf.len);
+              ninfo("Header bytes accumulated: %zu\n", cc->outbuf.len);
 
               /* Check for end of header */
 
@@ -663,7 +663,7 @@ static inline int cgi_interpose_output(struct cgi_conn_s 
*cc)
 
               nbytes_read = read(cc->rdfd, cc->inbuf.buffer,
                                  CONFIG_THTTPD_CGIINBUFFERSIZE);
-              ninfo("Read %d bytes from fd %d\n", nbytes_read, cc->rdfd);
+              ninfo("Read %zd bytes from fd %d\n", nbytes_read, cc->rdfd);
 
               if (nbytes_read < 0)
                 {
@@ -923,7 +923,7 @@ static int cgi_child(int argc, char **argv)
   /* Send any data that is already buffer to the CGI task */
 
   nbytes = hc->read_idx - hc->checked_idx;
-  ninfo("nbytes: %d contentlength: %d\n", nbytes, hc->contentlength);
+  ninfo("nbytes: %d contentlength: %zu\n", nbytes, hc->contentlength);
   if (nbytes > 0)
     {
       if (httpd_write(cc->wrfd, &(hc->read_buf[hc->checked_idx]), nbytes)

Reply via email to