[vlc-commits] access:http: change the scanf/printf format modifiers when using uintmax_t

Steve Lhomme git at videolan.org
Wed Jul 11 09:25:13 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 11 09:22:23 2018 +0200| [06d86ae4088fd49e69ff6e47c2f6f31e4530f975] | committer: Steve Lhomme

access:http: change the scanf/printf format modifiers when using uintmax_t

PRI(uxd)MAX for printf and SCN(uxd)MAX for scanf are supported in C99 and even
in MSVC 2013, unlike the j modifier.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=06d86ae4088fd49e69ff6e47c2f6f31e4530f975
---

 modules/access/http/chunked.c | 2 +-
 modules/access/http/file.c    | 8 ++++----
 modules/access/http/message.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/access/http/chunked.c b/modules/access/http/chunked.c
index 54652f3f89..549f590ebd 100644
--- a/modules/access/http/chunked.c
+++ b/modules/access/http/chunked.c
@@ -83,7 +83,7 @@ static block_t *vlc_chunked_read(struct vlc_http_stream *stream)
 
         int end;
 
-        if (sscanf(line, "%jx%n", &s->chunk_length, &end) < 1
+        if (sscanf(line, "%" SCNxMAX "%n", &s->chunk_length, &end) < 1
          || (line[end] != '\0' && line[end] != ';' /* ignore extension(s) */))
             s->chunk_length = UINTMAX_MAX;
 
diff --git a/modules/access/http/file.c b/modules/access/http/file.c
index ce101f60d6..322c0b2fbe 100644
--- a/modules/access/http/file.c
+++ b/modules/access/http/file.c
@@ -69,7 +69,7 @@ static int vlc_http_file_req(const struct vlc_http_resource *res,
         }
     }
 
-    if (vlc_http_msg_add_header(req, "Range", "bytes=%ju-", *offset)
+    if (vlc_http_msg_add_header(req, "Range", "bytes=%" PRIuMAX "-", *offset)
      && *offset != 0)
         return -1;
     return 0;
@@ -89,7 +89,7 @@ static int vlc_http_file_resp(const struct vlc_http_resource *res,
             goto fail;
 
         uintmax_t start, end;
-        if (sscanf(str, "bytes %ju-%ju", &start, &end) != 2
+        if (sscanf(str, "bytes %" SCNuMAX "-%" SCNuMAX, &start, &end) != 2
          || start != *offset || start > end)
             /* A single range response is what we asked for, but not at that
              * start offset. */
@@ -140,7 +140,7 @@ static uintmax_t vlc_http_msg_get_file_size(const struct vlc_http_msg *resp)
 
         uintmax_t end, total;
 
-        switch (sscanf(range, "bytes %*u-%ju/%ju", &end, &total))
+        switch (sscanf(range, "bytes %*u-%" SCNuMAX "/%" SCNuMAX, &end, &total))
         {
             case 1:
                 if (unlikely(end == UINTMAX_MAX))
@@ -159,7 +159,7 @@ static uintmax_t vlc_http_msg_get_file_size(const struct vlc_http_msg *resp)
         if (range == NULL)
             return -1; /* valid but helpless response */
 
-        if (sscanf(range, "bytes */%ju", &total) == 1)
+        if (sscanf(range, "bytes */%" SCNuMAX, &total) == 1)
             return total; /* this occurs when seeking beyond EOF */
     }
 
diff --git a/modules/access/http/message.c b/modules/access/http/message.c
index 8de2b55f33..9ea1566196 100644
--- a/modules/access/http/message.c
+++ b/modules/access/http/message.c
@@ -876,7 +876,7 @@ uintmax_t vlc_http_msg_get_size(const struct vlc_http_msg *m)
 
     uintmax_t length;
 
-    if (sscanf(str, "%ju", &length) == 1)
+    if (sscanf(str, "%" SCNuMAX, &length) == 1)
         return length;
 
     errno = EINVAL;



More information about the vlc-commits mailing list