* [PATCH v2] mctp: serial: replace memset with zero-initialization
@ 2026-05-30 22:46 Manish Baing
2026-05-31 9:12 ` David Laight
0 siblings, 1 reply; 5+ messages in thread
From: Manish Baing @ 2026-05-30 22:46 UTC (permalink / raw)
To: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, manishbaing2789
Use empty brace initialization (= {}) instead of explicit memset()
to zero-initialize stack memory to simplify the code.
No functional change.
Signed-off-by: Manish Baing <manishbaing2789@gmail.com>
---
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;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] mctp: serial: replace memset with zero-initialization 2026-05-30 22:46 [PATCH v2] mctp: serial: replace memset with zero-initialization Manish Baing @ 2026-05-31 9:12 ` David Laight 2026-05-31 9:36 ` Manish Baing 0 siblings, 1 reply; 5+ messages in thread From: David Laight @ 2026-05-31 9:12 UTC (permalink / raw) To: Manish Baing Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-kernel On Sat, 30 May 2026 22:46:46 +0000 Manish Baing <manishbaing2789@gmail.com> 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@gmail.com> > --- > 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; > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mctp: serial: replace memset with zero-initialization 2026-05-31 9:12 ` David Laight @ 2026-05-31 9:36 ` Manish Baing 2026-06-06 19:50 ` Manish Baing 0 siblings, 1 reply; 5+ messages in thread From: Manish Baing @ 2026-05-31 9:36 UTC (permalink / raw) To: David Laight Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-kernel 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@baylibre.com/ [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@gmail.com> wrote: > > On Sat, 30 May 2026 22:46:46 +0000 > Manish Baing <manishbaing2789@gmail.com> 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@gmail.com> > > --- > > 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; > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mctp: serial: replace memset with zero-initialization 2026-05-31 9:36 ` Manish Baing @ 2026-06-06 19:50 ` Manish Baing 2026-06-25 15:01 ` Manish Baing 0 siblings, 1 reply; 5+ messages in thread From: Manish Baing @ 2026-06-06 19:50 UTC (permalink / raw) To: David Laight Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-kernel 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@gmail.com> 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@baylibre.com/ > [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@gmail.com> wrote: > > > > On Sat, 30 May 2026 22:46:46 +0000 > > Manish Baing <manishbaing2789@gmail.com> 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@gmail.com> > > > --- > > > 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; > > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mctp: serial: replace memset with zero-initialization 2026-06-06 19:50 ` Manish Baing @ 2026-06-25 15:01 ` Manish Baing 0 siblings, 0 replies; 5+ messages in thread From: Manish Baing @ 2026-06-25 15:01 UTC (permalink / raw) To: David Laight Cc: jk, matt, andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-kernel Hi David, Just a quick follow-up on this thread. Please let me know how you would like me to proceed with this patch. Thanks & Regards , Manish On Sun, Jun 7, 2026 at 1:20 AM Manish Baing <manishbaing2789@gmail.com> wrote: > > 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@gmail.com> 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@baylibre.com/ > > [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@gmail.com> wrote: > > > > > > On Sat, 30 May 2026 22:46:46 +0000 > > > Manish Baing <manishbaing2789@gmail.com> 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@gmail.com> > > > > --- > > > > 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; > > > > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-25 15:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-30 22:46 [PATCH v2] mctp: serial: replace memset with zero-initialization Manish Baing 2026-05-31 9:12 ` David Laight 2026-05-31 9:36 ` Manish Baing 2026-06-06 19:50 ` Manish Baing 2026-06-25 15:01 ` Manish Baing
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox