From patchwork Mon Oct 21 23:26:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1180930 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Tk4dpU3i"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46xtDR1jrdz9sCJ for ; Tue, 22 Oct 2019 10:30:47 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id DBD0AC21E39; Mon, 21 Oct 2019 23:27:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 76CD8C21C29; Mon, 21 Oct 2019 23:27:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 54D6FC21DFD; Mon, 21 Oct 2019 23:27:02 +0000 (UTC) Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by lists.denx.de (Postfix) with ESMTPS id 13064C21CB6 for ; Mon, 21 Oct 2019 23:27:00 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id c6so18040252ioo.13 for ; Mon, 21 Oct 2019 16:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iNZ7PQM1HSioU60A3KrOsjLWsv8FmTUBuHK1D+qLxfk=; b=Tk4dpU3iXHEzinOEB9/2jNIb5CQNsuw/LBPMHld7VjAJYY7XG/QhenOQ/pJagKsTth bIFkDvq484fNCtjp4ucKyzX0czsp8fHfZLmEJG0Pjt9THpf6rwHhqP7ocKi+6hwGSVmz SdCodCDkcAKsIaLyG7SD9RzbhBZk8tt+gDeZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iNZ7PQM1HSioU60A3KrOsjLWsv8FmTUBuHK1D+qLxfk=; b=LQiEPjYY8AYTkHflnbFy+Hm+ek+ZOvKIwcSHzHRhFunbUJCUsGCLi+80AcOIim7NSf vp5N92f3ymUKEbK4KjZQFZRPW4sAU65CHHU+fXYYXIAUC7bM0fud2RGrmVV2PP9G84OU burbGmGkPO69mBvfboKIXcg2DL0goLiqMuvwHSiNw/cdM++Qu+8TlYtraYPZp3rnaw9m 8A+kvQ6vx04KauhQVt8rYR/8kBH7HDuZkhkZSyDl1kf/YhtZOpAaLRNqz1pLptek9emO Tot0JM9aEAqy+miObg98idoxLRENzrjhLGfSEtmpCz70FxntdLzK8FON8Firci0VLjVi V9TQ== X-Gm-Message-State: APjAAAUooOWIKP0DxMkZp+8hAoG7zW4D871xdkfXYjY+nsCxpOfi63rm RGP5xVR3OZmG3BPmabo5DiloDy65772oSQ== X-Google-Smtp-Source: APXvYqxK9oXEOAdY7Kq5eNlhYEw4/e5NRl+clJW6fCk0WrMu4/QpDqNAaI2dYIcS0olIF15lYFazjg== X-Received: by 2002:a05:6602:248e:: with SMTP id g14mr909505ioe.6.1571700418845; Mon, 21 Oct 2019 16:26:58 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id u190sm6879206ilc.36.2019.10.21.16.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 16:26:58 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 21 Oct 2019 17:26:45 -0600 Message-Id: <20191021232652.132164-4-sjg@chromium.org> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191021232652.132164-1-sjg@chromium.org> References: <20191021232652.132164-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2 03/10] tiny-printf: Reorder code to support %p X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With a bit of code reordering we can support %p using the existing code for ulong. Move the %p code up and adjust the logic accordingly. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: - Add a new patch to support %p without DEBUG lib/tiny-printf.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 430c3255bc5..c80c4f95ae0 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -157,7 +157,8 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr) * decimal). */ -static void pointer(struct printf_info *info, const char *fmt, void *ptr) +static void __maybe_unused pointer(struct printf_info *info, const char *fmt, + void *ptr) { #ifdef DEBUG unsigned long num = (uintptr_t)ptr; @@ -266,6 +267,21 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) div_out(info, &num, div); } break; + case 'p': +#ifdef DEBUG + 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 + */ + while (isalnum(fmt[0])) + fmt++; + break; +#else + islong = true; + /* no break */ +#endif case 'x': if (islong) { num = va_arg(va, unsigned long); @@ -287,18 +303,6 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) case 's': p = va_arg(va, char*); 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++; -#endif - break; case '%': out(info, '%'); default: