Re: [PATCH 4/4] iio: dac: Convert powerdown read callbacks to sysfs_emit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 29, 2021 at 2:21 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
> On Sat, Mar 20, 2021 at 2:54 PM Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:
> > On 3/20/21 12:01 PM, Joe Perches wrote:
> > > On Sat, 2021-03-20 at 08:14 +0100, Lars-Peter Clausen wrote:

...

> > >> -    return sprintf(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
> > >> +    return sysfs_emit(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
> > > rather than cast to bool, perhaps standardize to use !!(val & test)
> > I very much prefer the cast to bool since it semantically stronger.
>
> It's a mistake here. You have no special type for bool and you do
> transition int -> bool -> int.
> Why? !! is a proper way to deal with this.

Just to generalize: casting printf() parameters is a mistake in 99% cases.

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux