]> Git Repo - J-u-boot.git/blobdiff - lib/tiny-printf.c
aes: Allow to store randomly generated IV in the FIT
[J-u-boot.git] / lib / tiny-printf.c
index f661fc65054ae88e60684c235d689053c84de85c..0503c17341f6f003af077feb7e4f83b5d0a65f5d 100644 (file)
@@ -8,7 +8,6 @@
  * Copyright (C) 2004,2008  Kustaa Nyholm
  */
 
-#include <common.h>
 #include <log.h>
 #include <serial.h>
 #include <stdarg.h>
@@ -270,7 +269,8 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
                                }
                                break;
                        case 'p':
-                               if (CONFIG_IS_ENABLED(NET) || _DEBUG) {
+                               if (CONFIG_IS_ENABLED(NET) ||
+                                   CONFIG_IS_ENABLED(NET_LWIP) || _DEBUG) {
                                        pointer(info, fmt, va_arg(va, void *));
                                        /*
                                         * Skip this because it pulls in _ctype which is
@@ -312,7 +312,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
 
                        *info->bf = 0;
                        info->bf = p;
-                       while (*info->bf++ && width > 0)
+                       while (width > 0 && info->bf && *info->bf++)
                                width--;
                        while (width-- > 0)
                                info->putc(info, lz ? '0' : ' ');
@@ -366,16 +366,15 @@ int sprintf(char *buf, const char *fmt, ...)
 {
        struct printf_info info;
        va_list va;
-       int ret;
 
        va_start(va, fmt);
        info.outstr = buf;
        info.putc = putc_outstr;
-       ret = _vprintf(&info, fmt, va);
+       _vprintf(&info, fmt, va);
        va_end(va);
        *info.outstr = '\0';
 
-       return ret;
+       return info.outstr - buf;
 }
 
 #if CONFIG_IS_ENABLED(LOG)
@@ -383,14 +382,13 @@ int sprintf(char *buf, const char *fmt, ...)
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list va)
 {
        struct printf_info info;
-       int ret;
 
        info.outstr = buf;
        info.putc = putc_outstr;
-       ret = _vprintf(&info, fmt, va);
+       _vprintf(&info, fmt, va);
        *info.outstr = '\0';
 
-       return ret;
+       return info.outstr - buf;
 }
 #endif
 
@@ -399,16 +397,15 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 {
        struct printf_info info;
        va_list va;
-       int ret;
 
        va_start(va, fmt);
        info.outstr = buf;
        info.putc = putc_outstr;
-       ret = _vprintf(&info, fmt, va);
+       _vprintf(&info, fmt, va);
        va_end(va);
        *info.outstr = '\0';
 
-       return ret;
+       return info.outstr - buf;
 }
 
 void print_grouped_ull(unsigned long long int_val, int digits)
This page took 0.030266 seconds and 4 git commands to generate.