Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3385975rwi; Sun, 16 Oct 2022 09:57:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Bcit+EQvGTCC/TVVniy8qKocA2vQwiTI2ftPJJTYdVgyzG4DdZxVVor0ZJkxLEiNqZ5ST X-Received: by 2002:a17:90a:4607:b0:202:d8b7:2c1b with SMTP id w7-20020a17090a460700b00202d8b72c1bmr9153811pjg.64.1665939452616; Sun, 16 Oct 2022 09:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665939452; cv=none; d=google.com; s=arc-20160816; b=JH0zTxYsWEfbLocEUL84TN5N3macFA6eO+XyPEeooe5BifqIg/YW3r9SJ1Qz2do7Li 52NrcJQO1b3y4WnIYehwT39C7opWjWf2khRrNbLptmR8b4rP/gf+z02W5WAWqsLtbt/r k1GV2aVoiPUyjvzIvJ5WbQwOVyaSEkpJw5BW7qP+oDEVR075XkCJugMyo1KlUn/SnCJn cWDTPXD066byUTEFZoYYhH1Z+I2mLRSfKhfY7fjRv5ekDAXNQS0pGcJXXZbMga2BFp8x Y9nQzbhgsWTDtI3EJBXjXmIlthOnB7VuLGzSFulUijn4K8Esv+cwhTOs1hZQ7xLiXXTQ Z+1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ES67y3a7EjFbrGyFH0nNAnlVj5HkGzihsMIYbs/+N/0=; b=SJanHr/DIE6I0I5Dr2q2g6k1T3/shC403AIvpQh/j9t4kJ70XzMWd1Lju8fFFcsn4U BkUpFcK/78x43YGGowiUJ4eHXmZ60ZjW9Dj14H7jjEEZe1ig0LPxLLmn/OZd4oArG8Co nZjIv+A0x6/9vFKQ6JnNLkQH/79zK7QWBzFccJU0Xh7m5Sfr4GHdtKTNR8pos+VqlyxW d2X6SMn6GgfsmgFqk+32KTwmW4qelxXN3zRn1FWb3zgDSEotwuWkvKvPCbGXrZ7+PROB 5+G93srtfXiY8HZIdOE/CALghN0g4KVBBkugvDwC/qbX8f/DdHvypuK1iS2iWYrT53Bn tcDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XOfgOlSk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z20-20020aa78894000000b0053e7495a394si10491297pfe.141.2022.10.16.09.57.20; Sun, 16 Oct 2022 09:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XOfgOlSk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbiJPQhO (ORCPT + 99 others); Sun, 16 Oct 2022 12:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbiJPQhM (ORCPT ); Sun, 16 Oct 2022 12:37:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97E5036BCB; Sun, 16 Oct 2022 09:37:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3EB8060C35; Sun, 16 Oct 2022 16:37:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE971C433C1; Sun, 16 Oct 2022 16:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665938230; bh=37IDBlT9h1wZixGYlQIPgLNHS+XN/qSb58yicxbhiF8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XOfgOlSkHm3yqHMExfFnWyNVyDWRQS7ccWubWQ0qdXzEhMVXpNLVxdXfDcg7kVTHW 9HRMICv+7mSuEUCeQUn5ZliKPJzw3gBfT/hlw7bqQBPJsUO8LmkoO3xDpQFUkswakx G4Je9R+XnoY+rXjQfSDUOdAIT2trZDwc4MBPAO8hJFQWipiYgRnH94ZuQ7fBwtGW4d Q6AsSJDiQai0UAaqlipJmPmKhs4eXq1YeCmnEW/wRY9DWSlJq9+FX8t2OuCehPZgTJ 7VMFWLpjGn8D0JpWt8LwEFpqYgpubcscalUadg+nP690DJfJwbaWDxfw6EwlSf32A/ fvRkFXePmJvzA== Date: Sun, 16 Oct 2022 17:37:41 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Matti Vaittinen , Lars-Peter Clausen , Hartmut Knaack , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tools: iio: iio_utils: fix digit calculation Message-ID: <20221016173732.1c28ab90@jic23-huawei> In-Reply-To: References: X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Oct 2022 15:04:04 +0300 Matti Vaittinen wrote: > The iio_utils uses a digit calculation in order to know length of the > file name containing a buffer number. The digit calculation does not > work for number 0. > > This leads to allocation of one character too small buffer for the > file-name when file name contains value '0'. (Eg. buffer0). > > Fix digit calculation by returning one digit to be present for number > '0'. > > Fixes: 096f9b862e60 ("tools:iio:iio_utils: implement digit calculation") > Signed-off-by: Matti Vaittinen hi Matti Makes sense. Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan > --- > tools/iio/iio_utils.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c > index aadee6d34c74..8d35893b2fa8 100644 > --- a/tools/iio/iio_utils.c > +++ b/tools/iio/iio_utils.c > @@ -547,6 +547,10 @@ static int calc_digits(int num) > { > int count = 0; > > + /* It takes a digit to represent zero */ > + if (!num) > + return 1; > + > while (num != 0) { > num /= 10; > count++; > > base-commit: 4fe89d07dcc2804c8b562f6c7896a45643d34b2f