lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 30 Dec 2020 17:09:54 +0100
From:   Lars-Peter Clausen <lars@...afoo.de>
To:     Jonathan Cameron <jic23@...nel.org>,
        Jyoti Bhayana <jbhayana@...gle.com>
Cc:     Hartmut Knaack <knaack.h@....de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Rob Herring <robh@...nel.org>,
        Lukas Bulwahn <lukas.bulwahn@...il.com>,
        linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
        cristian.marussi@....com, sudeep.holla@....com,
        egranata@...gle.com, mikhail.golubev@...nsynergy.com,
        Igor.Skalkin@...nsynergy.com, Peter.hilber@...nsynergy.com,
        ankitarora@...gle.com
Subject: Re: [RFC PATCH v2 1/1] iio/scmi: Adding support for IIO SCMI Based
 Sensors

On 12/30/20 2:41 PM, Jonathan Cameron wrote:
> On Thu, 24 Dec 2020 03:19:21 +0000
> Jyoti Bhayana <jbhayana@...gle.com> wrote:
>
>> +	/*
>> +	 * The seconds field in the sensor interval in SCMI is 16 bits long
>> +	 * Therefore seconds  = 1/Hz <= 0xFFFF. As floating point calculations are
>> +	 * discouraged in the kernel driver code, to calculate the scale factor (sf)
>> +	 * (1* 1000000 * sf)/uHz <= 0xFFFF. Therefore, sf <= (uHz * 0xFFFF)/1000000
>> +	 *  To calculate the multiplier,we convert the sf into char string  and
>> +	 *  count the number of characters
>> +	 */
>> +
>> +	mult = scnprintf(buf, 32, "%llu", ((u64)uHz * 0xFFFF) / UHZ_PER_HZ) - 1;
> use sizeof(buf) instead of having 32 again.
>
Since this is just interested in the number of characters and not the 
string itself I believe it is possible to just call sprintf with NULL 
instead of a buffer. It will then still return the number of characters, 
but not print anything.

But maybe providing a ilog10() helper is the better approach.

Powered by blists - more mailing lists