Re: [PATCH v1] treewide, serdev: change receive_buf() return type to size_t

Johan Hovold
2023-12-15T16:32:39Z

On Fri, Dec 15, 2023 at 02:59:35PM +0100, Francesco Dolcini wrote:
> On Fri, Dec 15, 2023 at 02:51:09PM +0100, Johan Hovold wrote:
> > On Thu, Dec 14, 2023 at 06:01:46PM +0100, Francesco Dolcini wrote:
> > > From: Francesco Dolcini <francesco.dolcini@toradex.com>
> > >
> > > receive_buf() is called from ttyport_receive_buf() that expects values
> > > ">= 0" from serdev_controller_receive_buf(), change its return type from
> > > ssize_t to size_t.

> > > drivers/bluetooth/btmtkuart.c | 4 ++--
> > > drivers/bluetooth/btnxpuart.c | 4 ++--

> > > -static ssize_t btnxpuart_receive_buf(struct serdev_device *serdev,
> > > - const u8 *data, size_t count)
> > > +static size_t btnxpuart_receive_buf(struct serdev_device *serdev,
> > > + const u8 *data, size_t count)
> > > {
> > > struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev);
> >
> > A quick check of just the first two functions here shows that they can
> > return negative values.
>
> This is already fixed. Patches are in next.
>
> There were 3 buggy user of this API.
> - 1 patch was merged a few days ago in mainline
> - 2 patches are in next, the maintainer decided to wait for the next merge window
>
> commit 687d2de93b11 ("Bluetooth: btmtkuart: fix recv_buf() return value")
> commit 7954bbcdd7ea ("Bluetooth: btnxpuart: fix recv_buf() return value")
> commit c8820c92caf0 ("platform/surface: aggregator: fix recv_buf() return value")

Then why was that not mentioned in the patch (e.g. below the --- line)?

You are certainly not making it easy for reviewers, but good to see that
you thought about this, and I see now when reviewing the mail archives
that those bugs were the reason for this patch in the first place.

Johan