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: 57732 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp830260lbb; Fri, 4 Dec 2015 14:28:31 -0800 (PST) X-Received: by 10.194.178.202 with SMTP id da10mr19363087wjc.158.1449268111162; Fri, 04 Dec 2015 14:28:31 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id c125si8658604wmd.11.2015.12.04.14.28.30; Fri, 04 Dec 2015 14:28:31 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de 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 --- lib/tiny-printf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) -- 2.6.2 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot 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; +}