From patchwork Fri Dec 4 22:27:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 552903 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5A61D1402C4 for ; Sat, 5 Dec 2015 09:28:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3DAF94B6E1; Fri, 4 Dec 2015 23:28:21 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fqLi63uEsT-1; Fri, 4 Dec 2015 23:28:21 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 395944B6E3; Fri, 4 Dec 2015 23:28:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1AA54B65A for ; Fri, 4 Dec 2015 23:27:50 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9zutSGtuQ9RU for ; Fri, 4 Dec 2015 23:27:50 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by theia.denx.de (Postfix) with ESMTPS id AEBC34B656 for ; Fri, 4 Dec 2015 23:27:50 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 46621263C43 Received: by dusk.luon.net (Postfix, from userid 1000) id EF622203FA; Fri, 4 Dec 2015 23:27:41 +0100 (CET) From: Sjoerd Simons To: Simon Glass Date: Fri, 4 Dec 2015 23:27:37 +0100 Message-Id: <1449268061-805-4-git-send-email-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449268061-805-1-git-send-email-sjoerd.simons@collabora.co.uk> References: <1449268061-805-1-git-send-email-sjoerd.simons@collabora.co.uk> Cc: u-boot@lists.denx.de, Stefan Roese Subject: [U-Boot] [PATCH 3/7] lib/tiny-printf.c: Implement vprintf X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Implement both printf and vprintf for a bit more flexibility, e.g. allows the panic() function to work with tiny-printf. Signed-off-by: Sjoerd Simons Acked-by: Simon Glass Tested-by: Simon Glass --- lib/tiny-printf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 6766a8f..403b134 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -40,17 +40,14 @@ static void div_out(unsigned int *num, unsigned int div) out_dgt(dgt); } -int printf(const char *fmt, ...) +int vprintf(const char *fmt, va_list va) { - va_list va; char ch; char *p; unsigned int num; char buf[12]; unsigned int div; - va_start(va, fmt); - while ((ch = *(fmt++))) { if (ch != '%') { putc(ch); @@ -117,6 +114,17 @@ int printf(const char *fmt, ...) } abort: - va_end(va); return 0; } + +int printf(const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + ret = vprintf(fmt, va); + va_end(va); + + return ret; +}