Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98B7CC433EF for ; Thu, 3 Feb 2022 21:18:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA06883A27; Thu, 3 Feb 2022 22:18:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Yn1jAAjH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 930BD83A2D; Thu, 3 Feb 2022 22:18:33 +0100 (CET) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E8DEF819A2 for ; Thu, 3 Feb 2022 22:18:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x732.google.com with SMTP id 200so3188931qki.2 for ; Thu, 03 Feb 2022 13:18:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=l2nfpY1OK+KyDT8yCbuQIDHuE9Ov5NLK14y5lE4Bb0o=; b=Yn1jAAjH7N9CJD76lGr6kGLa7EUxRKDuttMbp3+I20otvuI8+H1m9QgYENsq5VDK62 2J1MmVgiOqgkf/EF6RwoJWKlTirqqZvnDnsp1oljxeWCAzzjv8Rq3KtdubKzsbDtKIVG 8i/d4/h2azI8hWODz/e2RnXx45Iwxut2O0VpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=l2nfpY1OK+KyDT8yCbuQIDHuE9Ov5NLK14y5lE4Bb0o=; b=XO6oeKTE+HToKqetx6DEJ7x3ryAm3mICVyxKvfMOXV2PXTcacYq9iGpPNc0hmiyoYF TCpJa923i1iBQadc+p79qWLnvC+1yz0AxL+U4far6uXo0eLB6jeeLnw9gitM5xFShyjd L2qW2nAsmIgJG7KOSGcemjKP5xKcqEytHZFYQE/tHKmbOCQPhgfNGfIMM1/TASqdRKQr DgNco9kDBcgIyBPxKIRTwU7ly2N+uAw+4H065MK7DAEgLGFAkPgAhF7g6dbW4N4WXmE6 9gzlWzjO9VyL9Uv8HcD76X6YIX+bxc3MOFeaWZ04sDGMUH3oqByjoX3O3Xx1mR6uW6V2 cIGg== X-Gm-Message-State: AOAM5312n3nswt06yeBrvqsSa910QLfuK3g0VIdCifAstQqnPY9dDQGy ZvvJQCI7JSiplAUD2ceQHAE0Hg== X-Google-Smtp-Source: ABdhPJwTSGGPe/49aJpWR9g/QTl9l+C9FFlm+hHzzjV2e5L2zlKjG+GYPpeQI4wMhnnp4RoEM6csPw== X-Received: by 2002:a05:620a:1a0b:: with SMTP id bk11mr14541723qkb.232.1643923109834; Thu, 03 Feb 2022 13:18:29 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id m22sm2757qkn.35.2022.02.03.13.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:18:29 -0800 (PST) Date: Thu, 3 Feb 2022 16:18:27 -0500 From: Tom Rini To: Sean Anderson Cc: Pali =?iso-8859-1?Q?Roh=E1r?= , Simon Glass , u-boot@lists.denx.de, Marek =?iso-8859-1?Q?Beh=FAn?= Subject: Re: [PATCH] malloc_simple: Remove usage of unsupported %zx format string Message-ID: <20220203211827.GZ7515@bill-the-cat> References: <20220203185137.4469-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wg2zgDM1gLxA7pbN" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean --wg2zgDM1gLxA7pbN Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 03, 2022 at 02:28:23PM -0500, Sean Anderson wrote: >=20 >=20 > On 2/3/22 2:25 PM, Sean Anderson wrote: > > Hi Pali, > >=20 > > On 2/3/22 1:51 PM, Pali Roh=E1r wrote: > >> Replace %zx by %lx and cast size_t to ulong. > >>=20 > >> U-Boot currently prints garbage debug output: > >> size=3Dx, ptr=3D18, limit=3D18: 4002a000 > >>=20 > >> With this change it prints correct debug data: > >> size=3D18, ptr=3D18, limit=3D2000: 4002a000 > >>=20 > >> Signed-off-by: Pali Roh=E1r > >=20 > > This qualifier is implemented in vsprintf, but not tiny-printf, > > and is widely used throughout the codebase. So perhaps a better > > fix might be=20 > >=20 > > diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c > > index f661fc6505..ad25bb7383 100644 > > --- a/lib/tiny-printf.c > > +++ b/lib/tiny-printf.c > > @@ -229,7 +229,8 @@ static int _vprintf(struct printf_info *info, const= char *fmt, va_list va) > > ch =3D *fmt++; > > } > > } > > - if (ch =3D=3D 'l') { > > + if (ch =3D=3D 'l' || > > + (sizeof(size_t) >=3D sizeof(int) && ch =3D= =3D 'z')) { > > ch =3D *(fmt++); > > islong =3D true; > > } > > -- > >=20 > > which is not completely correct (since tiny-printf doesn't > > support long longs), but will address the core issue. >=20 > Actually, we probably need something more like >=20 > if (ch =3D=3D 'z') { > ch =3D *(fmt++); > islong =3D sizeof(size_t) >=3D sizeof(int); > } >=20 > so that 32-bit arches still print the integer. Right, but then we grow tiny-printf on the boards that really need to be super concerned about space. We have typically done what Pali proposes here before of make the subset of code that runs under tiny-printf use more restrictive and possibly slightly less optimal format characters. --=20 Tom --wg2zgDM1gLxA7pbN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmH8RqMACgkQFHw5/5Y0 tyzzTwv/S05ly1yKE+CBWNJjjNU8F3SwC/fwhPQlEflj+zRRfZmg4PylNXXJ+OeU 4lspKznxMaMR8vvBku0nUQ4rtxlKBEuYuDHB3OeVmpBgyXH2/wWFe/NHD0UfwlBr KmWDXIGNKFOY2CkGD+tKYDmR6rSKaIjpTEwcCsxhFZWN+R6Q9bZRRv+woUhz+lpf xaQ1BBtI5gnHg2ghmUcv2r0aC9TZ5ZXfGNNwvnJRzTtylXbxpjK/LzdtoLqX0T8M +DCfy5gktpZWYi/MvfG5tYbpJmm0frpqrGKz1QG2n8ct/5PCR2qJTdWjqkhUguUb zUT3OnD+r5/aGmuou2pWOv5ogAjeIKdYrY2GFi9awfudTCRxbdDKqWmWlLnoiCny LcVGknnhtq8MuX+/hUepDEh/x6tggK58U2QSCJC/+jKrNDeJPHCZVak/PlHScQ9G o1RNJd+1NDjkQ8cHMRRy+ZFm5k2ujjvhGYdWrZaW62JqhmBVXC+I3z6UX8YOn9CC nh7718xe =aU7K -----END PGP SIGNATURE----- --wg2zgDM1gLxA7pbN--