Re: [PATCH 0/7] hwmon: zero-initialization instead of memset
From: Guenter Roeck
Date: Sun Jun 07 2026 - 12:12:39 EST
On 5/30/26 15:13, Manish Baing wrote:
Hi all,
This patch series cleans up memory initialization across several
hardware monitoring (hwmon) drivers by replacing explicit memset() calls
with empty brace initialization (= {}).
Following similar cleanups in the IIO subsystem [1], this series updates
these drivers to stop using memset() for stack memory initialization.
As noted in those discussions [2], using empty brace initialization (= {})
is the preferred approach.
Beyond simple replacements, a few drivers (nct6683, nct6775-platform, it87)
were using memset() inside a for-loop. To fix this, the variable
declarationwas moved directly inside the loop and zero-initialized there.
This safely resets the data on every iteration and makes the code much
cleaner.
Testing:
- Compiled all modified files using `make W=1` with no warnings or errors.
[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/
That discussion does not fully address a problem I had seen previously,
where {} did _not_ zero-fill all holes, causing subsequent memcmp()
failures on affected data structures. It took a lot a lot of debugging
to find and fix that problem. Given that, I am not inclined to accept
this series unless someone convinces me that it fixes an actual problem
_and_ that each and every instance of the changes is not used in a
subsequent memcmp().
Guenter