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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251031161331.0f0ef347@pumpkin>
Date: Fri, 31 Oct 2025 16:13:31 +0000
From: David Laight <david.laight.linux@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Jonathan Cameron <Jonathan.Cameron@...wei.com>,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, Jyoti Bhayana
 <jbhayana@...gle.com>, Jonathan Cameron <jic23@...nel.org>, David Lechner
 <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, Andy
 Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v1 1/1] iio: common: scmi_sensors: Replace const_ilog2()
 with ilog2()

On Fri, 31 Oct 2025 14:51:57 +0200
Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:

> On Fri, Oct 31, 2025 at 12:45:30PM +0000, David Laight wrote:
> > On Fri, 31 Oct 2025 11:54:30 +0200
> > Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:  
> > > On Fri, Oct 31, 2025 at 09:43:36AM +0000, David Laight wrote:  
> > > > On Fri, 31 Oct 2025 08:45:00 +0100
> > > > Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:    
> 
> ...
> 
> > > > >  		tstamp_scale = sensor->sensor_info->tstamp_scale +
> > > > > -			       const_ilog2(NSEC_PER_SEC) / const_ilog2(10);
> > > > > +			       ilog2(NSEC_PER_SEC) / ilog2(10);    
> > > > 
> > > > Is that just a strange way of writing 9 ?    
> > > 
> > > Why? It's correct way of writing log¹⁰(NSEC_PER_SEC), the problem here is that
> > > "i" people do not think about :-)  
> > 
> > Even without the "i" the division could easily give 8.999999.
> > So you'd be relying on rounding to get the required integral value.
> >   
> > > But we have intlog10(), I completely forgot about it.  
> > 
> > And it isn't the function the code is looking for.
> > (The result is shifted left 24 and it doesn't have an optimisation
> > for constants.)  
> 
> Do you have an idea how to improve that?

Not sure I'd want to get cpp to generate a high-precision log.
It if definitely doable, but will be a mind-blowing mess.
(and I'm not sure how many MB the expanded line would be).
An ilog10() would be easier (probably looking like const_ilog2()).

But for this code just use '+ 9' and add a suitable comment :-)

	David



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ