Re: [PATCH v2 3/3] iio: chemical: atlas-ezo-sensor: add support for O2 sensor

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

 



On Tue, Jul 21, 2020 at 11:46 AM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
>
> On Mon, Jul 20, 2020 at 10:05 AM Matt Ranostay
> <matt.ranostay@xxxxxxxxxxxx> wrote:
> >
> > Add support for the Atlas EZO O2 chemical sensor which required
> > some refactoring of the driver and parsing of i2c transfer.
> >
> > Sensor data is converted by the scaling value from percent to
> > IIO_CONCENTRATION.
>
> ...
>
> > +static void atlas_ezo_sanitize(char *buf)
> > +{
> > +       char *ptr = strchr(buf, '.');
> > +
> > +       if (!ptr)
> > +               return;
> > +
> > +       for (; *ptr; ptr++)
> > +               *ptr = *(ptr + 1);
> > +}
>
> NIH of memmove()? Why?

Mainly since I forgot that POSIX function. I'll fix it up when possible

- Matt

>
> And actually to avoid strlen() you may do it other way around, i.e
> shift integer part one character right and return new buffer pointer.
>
>
> if (!ptr)
>   return buf;
>
> memmove(buf + 1, buf, ptr - buf);
> return buf + 1;
>
> --
> 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