Re: [PATCH v2] mctp: serial: replace memset with zero-initialization
From: Manish Baing
Date: Sat Jun 06 2026 - 15:51:23 EST
Hi David,
Just a quick follow-up on this thread. When you have a moment, I would
love to hear your thoughts on my previous email.
Please let me know how you would like me to proceed with this patch.
Thanks & Regards ,
Manish
On Sun, May 31, 2026 at 3:06 PM Manish Baing <manishbaing2789@xxxxxxxxx> wrote:
>
> Hi David,
>
> I understand that this might just be unnecessary churn for the
> networking subsystem, and I am perfectly fine dropping the patch if
> that is the case.
>
> However, for my own learning, I would love to get your perspective on
> this. I was carrying over a pattern from recent cleanups in the IIO
> subsystem [1],
> as empty brace initialization was noted as the preferred approach in
> those discussions (including by Kees Cook [2]).
>
> Is the reasoning behind that recommendation just not applicable to
> netdev,or is the policy here strictly against code churn unless it
> fixes a tangible bug?
>
> Thanks for the guidance.
>
> [1]: https://lore.kernel.org/all/20250611-iio-zero-init-stack-with-instead-of-memset-v1-0-ebb2d0a24302@xxxxxxxxxxxx/
> [2]: https://lore.kernel.org/linux-iio/202505090942.48EBF01B@keescook/
>
> Regards,
> Manish
>
>
> On Sun, May 31, 2026 at 2:42 PM David Laight
> <david.laight.linux@xxxxxxxxx> wrote:
> >
> > On Sat, 30 May 2026 22:46:46 +0000
> > Manish Baing <manishbaing2789@xxxxxxxxx> wrote:
> >
> > > Use empty brace initialization (= {}) instead of explicit memset()
> > > to zero-initialize stack memory to simplify the code.
> > >
> > > No functional change.
> >
> > Isn't it also entirely pointless?
> >
> > -- David
> >
> > >
> > > Signed-off-by: Manish Baing <manishbaing2789@xxxxxxxxx>
> > > ---
> > > Changes in v2:
> > > - Fixed a compilation error caused by a duplicate variable declaration caught
> > > by the kernel test robot.
> > >
> > > drivers/net/mctp/mctp-serial.c | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/mctp/mctp-serial.c b/drivers/net/mctp/mctp-serial.c
> > > index 26c9a33fd636..df721ca4e07b 100644
> > > --- a/drivers/net/mctp/mctp-serial.c
> > > +++ b/drivers/net/mctp/mctp-serial.c
> > > @@ -536,13 +536,12 @@ struct test_chunk_tx {
> > >
> > > static void test_next_chunk_len(struct kunit *test)
> > > {
> > > - struct mctp_serial devx;
> > > + struct mctp_serial devx = { };
> > > struct mctp_serial *dev = &devx;
> > > int next;
> > >
> > > const struct test_chunk_tx *params = test->param_value;
> > >
> > > - memset(dev, 0x0, sizeof(*dev));
> > > memcpy(dev->txbuf, params->input, params->input_len);
> > > dev->txlen = params->input_len;
> > >
> >