lib: Suppress E when writing error-string output
authorSimon Glass <sjg@chromium.org>
Sun, 30 Jul 2023 17:15:13 +0000 (11:15 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Wed, 9 Aug 2023 15:31:11 +0000 (23:31 +0800)
When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the
format string. Fix this.

Fixes: 7f331941321 ("lib: Support printing an error string")
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
lib/vsprintf.c

index e87503e..e14c6ca 100644 (file)
@@ -680,8 +680,10 @@ repeat:
                        break;
 
                case 'd':
-                       if (fmt[1] == 'E')
+                       if (fmt[1] == 'E') {
                                flags |= ERRSTR;
+                               fmt++;
+                       }
                /* fallthrough */
                case 'i':
                        flags |= SIGN;
@@ -725,7 +727,6 @@ repeat:
                        ADDCH(str, ' ');
                        for (p = errno_str(num); *p; p++)
                                ADDCH(str, *p);
-                       fmt++;
                }
        }