tiny-printf: Reduce size by removing ctype
authorSimon Glass <sjg@chromium.org>
Mon, 21 Oct 2019 23:26:43 +0000 (17:26 -0600)
committerSimon Glass <sjg@chromium.org>
Sun, 27 Oct 2019 16:56:41 +0000 (10:56 -0600)
The ctype array is brought into the image, adding 256 bytes, when it is
unlikely to be needed. The extra code for %p is only present when DEBUG
is defined, so let's drop ctype as well unless DEBUG is defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
lib/tiny-printf.c

index ebef92fc9f6b3c938bfd4abe7894483915b05768..632b4249142e561eb0dea0a01e095b0d8e7efcbd 100644 (file)
@@ -289,8 +289,15 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
                                break;
                        case 'p':
                                pointer(info, fmt, va_arg(va, void *));
                                break;
                        case 'p':
                                pointer(info, fmt, va_arg(va, void *));
+                               /*
+                                * Skip this because it pulls in _ctype which is
+                                * 256 bytes, and we don't generally implement
+                                * pointer anyway
+                                */
+#ifdef DEBUG
                                while (isalnum(fmt[0]))
                                        fmt++;
                                while (isalnum(fmt[0]))
                                        fmt++;
+#endif
                                break;
                        case '%':
                                out(info, '%');
                                break;
                        case '%':
                                out(info, '%');