From patchwork Thu May 30 08:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1941571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=lf2VwpKB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::838; helo=mail-qt1-x838.google.com; envelope-from=swupdate+bncbcwivbv7sugrbrxn4czamgqegxw7ipy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-qt1-x838.google.com (mail-qt1-x838.google.com [IPv6:2607:f8b0:4864:20::838]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VqfMK2TLPz23vC for ; Thu, 30 May 2024 18:20:29 +1000 (AEST) Received: by mail-qt1-x838.google.com with SMTP id d75a77b69052e-43fb02db8basf7441981cf.0 for ; Thu, 30 May 2024 01:20:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717057223; cv=pass; d=google.com; s=arc-20160816; b=uIRGjopwgz4gFM+Z/fUzFXF5e+aezMOcZXbOpQRIRa51Cm9qUYQP3LBIyRLMBwBJRA m1uNoZsR2ARinD/mY0Jy5ir1L/gdl0bV9CDQcWB/BL7qJYDnW3JU49b2LnbuyWDIn5QG VBr8qHnsRT2giirwdI0Z1fPJm5e91iqSn0RIbTpmIN2saJav5psBUOD9nkQz1pTr92EY ztivvc5gA+ggJG7+1PYQjb5nXh2FYEe4YYY0pbTV3LC7PJ7pcC/dZWI6ll6GdguMGT1l Gg2N4N89b452pjGWWliuufZSEpAx9S6421E2iaytJL4O3FA5g08ubs6V1tUEdTdervBZ UNVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=XS2kP+AkStd0BHGKH618WvF6sDNCRL7VvmelrMMFxBA=; fh=knEjJ2jdCVqAcuOnTeUGWD99K7cYhspTRyWK07+0LDA=; b=QO5tRbWqs9gylKr/Y0oe/fSsv5afkER4SZXDnpxLzUEsOqAvKoTQf7I7f4rHo8S/pU trkgKjKwr3Sx14mmpi9zKbzyeFeVXbiAS2t5p/o1HXOTHQlUYHYP+uZdcw2vfR+YPQ5s ybrNkmtnVg+3aDTXEDFyg9URzcgzQY/ZK4wSqMZLuMlW4y31V0O2wStLwJps9nazNK02 ufnQmy9HudmV3n+LCsHbQ6OD72xvFRarkxAPEck9UZWZmtluJwaq1lw8G1nWhDIbRFRB +mLcwKgXHcn7nz5Hwseh1LClPop62aDvmCU8bY0QgIBboXotkoko5z8KlayY7lGyfa7A 7YHg==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b="WYmY/bXW"; dkim=pass header.i=@atmark-techno.com header.s=google header.b=b0EcgU8w; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1717057223; x=1717662023; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=XS2kP+AkStd0BHGKH618WvF6sDNCRL7VvmelrMMFxBA=; b=lf2VwpKBcyiVVc9bzOLxnncegctfJbOtbiBPTIDJc3hF2eCVFoSoEaMNYLYbSgs2nv wkczez8cISYbfIOrC0IsE8XWobWSxWXPnF38sUwCChCcidg2Sl7MDXz/Max1pvsTVFC1 7Rup/rgVmFz5cR6LXvJAHk2p7sgEz11FSStkgYLIcbzECZ9NXJIkNp3smJbSk50MqFqD OjHXTXe/iDUg+L6w9X5ti40ufnsc7uSvh5vaOY9boYQy09kBQaRzyIFdMl5+a69Jbuub 81XOaZGkwEy4iAgwyLHurg6ixCkoFtrW/PYjZCtPAFvn7737wdKKsljcpZA5bEd/Y/TF SKXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717057223; x=1717662023; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=XS2kP+AkStd0BHGKH618WvF6sDNCRL7VvmelrMMFxBA=; b=bO0cNu8mOTe5l8hDkfFOvy6afDeke4BS3gnzfAjJWI1bTEhkBqShcT0OPmvq15nWTt cW3ckTttcu0tRl0kJkkHB1D977q8ZVxG0L3IkGwtETKjXjp57FFvaAZs6V1KSHqHWqxt OuGW8xbN5kGqZA1nkfpy0jTn6+ZcwaJegkwYcd3rorYGk2cX1bgDO1Q8WDwbRctZbS6e kyiDsi6K3g592GKJ3kY1T+J/dfpwJfTHUIEoHw555Da5wPM8geEEWloYFay9qlEBlDcn HJSxZulXGr+QLy7U0j8OcuzwrGsitIyv/SHz52HgEfcGj8tcv2NONkEgaRrptJoB52VL QhBA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUEfcXHhft5AlLuru+MdtDuoTk7DZ0xXLq/3hj86lRTnDDV77Ld61uDiOT/SEevi15B1sA6835GGqklDD9oeSCl+ekWtrtM+fB6eLq5dQ== X-Gm-Message-State: AOJu0YxkV8WI5FX5HY2bL36IAQqVaVdffkm0sWmx3KbQViozPbjUMSRU iAx6a+HL97291AcW4xZ22qIwKOr1SrAGqQ6oLWPPmR+gdJ1RqX8F X-Google-Smtp-Source: AGHT+IE6OiHRsPeRREcMXB6W6Hih2HWoVsNo+dhXCfa6Ct+owcG4/YdABA2rN41Ce8iJuI4E8pKZIw== X-Received: by 2002:ac8:5a10:0:b0:43e:404a:890c with SMTP id d75a77b69052e-43fe92bb680mr15462361cf.19.1717057223030; Thu, 30 May 2024 01:20:23 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac8:7e89:0:b0:43a:fa0d:6a75 with SMTP id d75a77b69052e-43fe915bef2ls1244541cf.1.-pod-prod-01-us; Thu, 30 May 2024 01:20:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU5evMEEl79nAX9vKhQ5moPwc+3ZdjL+j1Nk3PxJV0qeD0xeJ52mhTG8iA99gIiM01FZsiKA+cwBD+UFPt//gw4UJ+wtI09w3rb X-Received: by 2002:a05:622a:1aa1:b0:43e:3c19:a2de with SMTP id d75a77b69052e-43fe932fc45mr18804081cf.63.1717057221306; Thu, 30 May 2024 01:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717057221; cv=none; d=google.com; s=arc-20160816; b=DsF+jGI4rhTiy6xirV7gkx+VdaXit8KLhSN4g3uMG15b7iUnuqkhzzGtWEqVbaZMsV 9Eg3BAcaOWp2oWjg0D+tU2dBOiwTMPEAeHn01xwM+arI3IZQnBlFzClNf0u/tjzOphZP yE1Nb3fjJIrxZE2M95227wDixIiMjmAXwSgtFIpwXvkuxNpEFuhUrA4tnLf6CfOmM1sM I68qjqSkTUU+FkFpHSBMYIyhX3dvUSaIqhpoIs0IYM5rsE+jk14H2CoChPtZk9zFOXcv UuU+qEAANYEXd6suH3gKVf4sy0Lzbd4+XguGUb8qMpBFmKsVe6FFI/fZ+nP08xYAqiV7 7Bhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=Q8iKS1aiUEQu7QqdAyzfcBfoBUGjmqm91B0GCAmDDVc=; fh=SMKbIGiMD41scdE59NQSgS4d6KXSLHA+dhdam17XO8c=; b=QDkNpStBdqORLh4j0Tg/TTXeMrE5rx219OHEPV/jYkhxD9FSq3FnGW0b5u0mlb95FG aVe4BTD3nDeEm56snZyo0ug/mgOHky/dyk8GVhU4z8ZBJBWRpX16OYViBAfn7eIi9eSc naXEXxLz9XBWQ1R3uqYLZykAT1LL+6IBhVL5SgIUXN3+GuL/aRSdyl/PjN+KmzOGLnXa PQ/fuzVOXnGeZw1QLhIokNBq/EO57dZ41pRDfAovo9dYj6Z7gMtPi3odRgmjbvg1Hd9u Mk9HHHqLjOsYBX+fCNJlOMSkt1//TjTJ5x5+wb0ly30wLGLT1BNi7UPb4EgtwQ0PjcrK +A9Q==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b="WYmY/bXW"; dkim=pass header.i=@atmark-techno.com header.s=google header.b=b0EcgU8w; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id d75a77b69052e-43fb17c2bf2si8906711cf.2.2024.05.30.01.20.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 01:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id C9DDF9AC for ; Thu, 30 May 2024 17:20:18 +0900 (JST) Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 644F4933 for ; Thu, 30 May 2024 17:20:17 +0900 (JST) Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-250719d64afso237642fac.3 for ; Thu, 30 May 2024 01:20:17 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUYzydP2QLR4MUElpfDPYlDp+3xbcrFzRCQ6Gk7DJqkCpTbcwYYV8G2o1sE1Sefto91VsHhRH9XeD1XtH2R32uyTWeEbW4aM9ok X-Received: by 2002:a05:6871:58a:b0:24d:9c68:4e9e with SMTP id 586e51a60fabf-25060d3262dmr1636746fac.45.1717057215974; Thu, 30 May 2024 01:20:15 -0700 (PDT) X-Received: by 2002:a05:6871:58a:b0:24d:9c68:4e9e with SMTP id 586e51a60fabf-25060d3262dmr1636727fac.45.1717057215513; Thu, 30 May 2024 01:20:15 -0700 (PDT) Received: from pc-0182.atmarktech (35.112.198.104.bc.googleusercontent.com. [104.198.112.35]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-701d44144adsm3716052b3a.58.2024.05.30.01.20.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2024 01:20:15 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sCb1C-005zOd-0L; Thu, 30 May 2024 17:20:14 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: shinya.koga@atmark-techno.com, Dominique Martinet Subject: [swupdate] [PATCH v3 1/4] util: ustrtoull: error on bad suffixes Date: Thu, 30 May 2024 17:20:04 +0900 Message-Id: <20240530082007.1427631-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530082007.1427631-1-dominique.martinet@atmark-techno.com> References: <20240530082007.1427631-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b="WYmY/bXW"; dkim=pass header.i=@atmark-techno.com header.s=google header.b=b0EcgU8w; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , ustrtoull would check suffixes for k/K/M/G, but just ignore anything else: - handle m/g as well (why k but not others?) - clearly error if unrecognized suffix is used Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- v2->v3: remove error message core/util.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/util.c b/core/util.c index 84df7ad09388..70f0d28f6d61 100644 --- a/core/util.c +++ b/core/util.c @@ -721,9 +721,11 @@ unsigned long long ustrtoull(const char *cp, char **endptr, unsigned int base) switch (*endp) { case 'G': + case 'g': result *= 1024; /* fall through */ case 'M': + case 'm': result *= 1024; /* fall through */ case 'K': @@ -737,6 +739,12 @@ unsigned long long ustrtoull(const char *cp, char **endptr, unsigned int base) } else { endp += 1; } + case 0: + break; + default: + errno = EINVAL; + result = 0; + goto out; } out: