From patchwork Thu Aug 5 21:22:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matwey V. Kornilov" X-Patchwork-Id: 492277 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp672253jap; Thu, 5 Aug 2021 14:23:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYQXKPMR80PYLM8AxM3fc1yy81c0m934pFtRrTYSRaoos2tCJ4K2TflXtbgVlWPMLFVItF X-Received: by 2002:a17:906:3707:: with SMTP id d7mr6798570ejc.127.1628198620855; Thu, 05 Aug 2021 14:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628198620; cv=none; d=google.com; s=arc-20160816; b=lRoDFOK8Fh5Twzh+3AbeaAHhzPab2j2gbixrwZ3pBnTcDoIDW0E03p7nrxy1n8Lj0P /LnonM9TXjYUr9T5OyKRSY8lhfsMsHiRdKgJp4uSxVZFJyjnS00P26mWhPadQmiiWAvA Cg71vhG8xqRkWTxyghit9RDetxgHztBNLLqjJEuj2qHu1vEbv54UGnQR98l0wONOfDGe 4a7GhY9nZnCoCvKnWi5FPAZq6fclcpB5w1wPnQFstg/CWFJs4nyGSJbfxmCj+xBAyYPi 8NzPAoVDjv7uWmjuv0Dw6VGPbsXscVC9kBN4Jrb3pNitkKd8Ux5DSTClBcK8xh3zCy6K ZB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=eVw/NaADzh1MZq+4faVUK2tnxAzqPHo67UT32epnkBE=; b=OjanpxV5JZ7qZu3U7cSrKXCrQu5G4p/uQabylZq3isUb0a429N9F/HoTTFjEI4gsk+ Eig5BPpJxo4WI58hULIJyMWyMbgOujnSagzHrj2MeuuBvOlcV00B3xJzzxhr7GSDGFjj TKQAIU81i3ADLpdwRGSxHErxELNZorrcu+reya9Vlrils8sgvq37udy5Etn9cf+qujt1 fxvgevkwwuTdQBuEbKsxiN4x7Ct4hVlPqBANgdh+f+epqg3xqTxCK5akeAmKfliyBU8v A59p3cb57lnr+gRPFPF0CUrxbuUaaqdcnA1p9yceiojkgw/GWc/ctz7/JNSx/CmEPrcq vCOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fUH4r9vv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id x16si6848103edd.522.2021.08.05.14.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 14:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fUH4r9vv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A6C482BF1; Thu, 5 Aug 2021 23:23:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fUH4r9vv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E425982C28; Thu, 5 Aug 2021 23:23:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (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 A0FC382BF1 for ; Thu, 5 Aug 2021 23:23:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matwey.kornilov@gmail.com Received: by mail-lf1-x12c.google.com with SMTP id c24so10478066lfi.11 for ; Thu, 05 Aug 2021 14:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eVw/NaADzh1MZq+4faVUK2tnxAzqPHo67UT32epnkBE=; b=fUH4r9vvL/3Q+9Q5nKL/s0Toa1bzPzuFKTxGgcV4/UDS+OF/vdKpkIzJ01r0b3jPOX Ib9Q4mzXAXyq6LE/KzOd2+GNYwN4acp4ANtt4w0RkZM/9lNfeFQQJXYH6JT6t704leFM 3/kNS8N/xhr3vRxNbdPewMwcj0w1Q3z2J26rjkaa13+Oapgvv1f7SjvezW23xjevIJ7K pB3eNEnJfffAxdWvqPfMMjyvpHr5pJNPhfY2Zwdcy+iSNKdwMOaEDc+EkbwQpROWHzV5 3/Y0WA3u3zHFd4GxI44uBWUkWZeF1OFcWM2WKZJovQN6k+J5B13IR4sikEVZspCxNglF bYkA== 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:mime-version :content-transfer-encoding; bh=eVw/NaADzh1MZq+4faVUK2tnxAzqPHo67UT32epnkBE=; b=JoGImeJAxTowQKY7UwrhR/lJuf49YGr84n9mQMi63OjtseeLCDytufpSHYrKFSGvdf DJFf67rnRACHAFAXRKIEF+Ae5wSthpABrR5CtdgLBOZLb8+nocsTdDkYjd9YnpKIJFVA 51WC3kWgeVH2w3H4Ts+CToiKIpvDIWLoYKT++aoeA8eZpi68XelDAFgOSeefVz9pKYHd JaIPyLh8E6e3Kuixq1BxbTy0OKoqbnytDZS3tvkg2M8VtQR6nDMtyxmXegHLLcScCToM t66bJqn68tDVdzxVGXXia2sLcJJvq02DuxARKEWMW/xHeTTTRB0lh1zxLO1SMavkNVUE KKpw== X-Gm-Message-State: AOAM53257K4epoEC+s3SZQuNdtfS6tTMNTw0iv07iSr5WHf/0PIL1cQc jHLh47ijR3ylmB3jmU66tlE= X-Received: by 2002:a05:6512:3e24:: with SMTP id i36mr4963431lfv.169.1628198585595; Thu, 05 Aug 2021 14:23:05 -0700 (PDT) Received: from oak.local ([2001:470:28:561:2991:a833:31da:2248]) by smtp.gmail.com with ESMTPSA id b13sm494727ljq.53.2021.08.05.14.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 14:23:04 -0700 (PDT) From: "Matwey V. Kornilov" To: sjg@chromium.org, sr@denx.de, trini@konsulko.com, xypron.glpk@gmx.de Cc: u-boot@lists.denx.de, "Matwey V. Kornilov" Subject: [PATCH] display_options: Do not use %llu in print_size Date: Fri, 6 Aug 2021 00:22:58 +0300 Message-Id: <20210805212258.11027-1-matwey.kornilov@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean tiny-printf variant doesn't know how to handle %llu format string, but both tiny-printf and print_size can meet in SPL when TFTP is used to obtain main u-boot image. This is known to lead to critical boot issue at AM335x platform when printf is catched in infinite loop. To avoid such issues and make print_size function tiny-printf friendly, use %u instead of %luu. Note, that the size value is guaranteed to be less than 1024 in this conditional branch, so the cast to unsigned int is safe. Signed-off-by: Matwey V. Kornilov --- lib/display_options.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.31.1 Reviewed-by: Simon Glass diff --git a/lib/display_options.c b/lib/display_options.c index c08a87e316..4da1f5244f 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -107,7 +107,12 @@ void print_size(uint64_t size, const char *s) } if (!c) { - printf("%llu Bytes%s", size, s); + /* + * SPL tiny-printf is not capable for printing uint64_t. + * We have just checked that the size is small enought to fit + * unsigned int safely. + */ + printf("%u Bytes%s", (unsigned int)size, s); return; }