You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/10/10 15:35:48 UTC

[GitHub] ccollins476ad commented on a change in pull request #1451: tinyprintf: Add support for parametrized field width

ccollins476ad commented on a change in pull request #1451: tinyprintf: Add support for parametrized field width
URL: https://github.com/apache/mynewt-core/pull/1451#discussion_r224130476
 
 

 ##########
 File path: libc/baselibc/src/tinyprintf.c
 ##########
 @@ -282,7 +282,10 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
             }
 
             /* Width */
-            if (ch >= '0' && ch <= '9') {
+            if (ch == '*') {
+                p.width = intarg(0, 1, &va);
 
 Review comment:
   It might be a good idea to do a range check here.  A standard-compliant `printf` allows an `int` variable width, but tinyprintf's `width` member is an `unsigned char`.  I'm *not* suggesting you change this to support the full `int` range (that doesn't seem like a worthwhile change).  Perhaps this code could clamp the width to `[0, UCHAR_MAX]`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services