[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231121083246.wg5qtej6cll3snlg@pengutronix.de>
Date: Tue, 21 Nov 2023 09:32:46 +0100
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Markus Elfring <Markus.Elfring@....de>
Cc: kernel@...gutronix.de, kernel-janitors@...r.kernel.org,
Mark Brown <broonie@...nel.org>, linux-spi@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>, cocci@...ia.fr,
Amit Dhingra <mechanicalamit@...il.com>
Subject: Re: spi: cadence-xspi: Drop useless assignment to NULL
On Tue, Nov 21, 2023 at 09:19:13AM +0100, Markus Elfring wrote:
> >>>>> Static structs are initialized with zeros for unspecified fields.
> >>>>> So there is no advantage to explicitly initialize .remove with NULL
> >>>>> and the assignment can be dropped without side effects.
> …
> > Removing = 0 assignments should be carefully reviewed. I skimmed the
> > changes to drivers/pwm and would oppose to both changes.
>
> How does this development view fit to information from the patch description?
They are syntactically fine as they don't change the semantic of the
code. But assignments to NULL (and still more to 0) also serve the human
reader as documentation.
Look at the patch for drivers/pwm/pwm-samsung.c:
diff -u -p a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -478,21 +478,17 @@ static const struct samsung_pwm_variant
static const struct samsung_pwm_variant s3c64xx_variant = {
.bits = 32,
- .div_base = 0,
.has_tint_cstat = true,
.tclk_mask = BIT(7) | BIT(6) | BIT(5),
};
static const struct samsung_pwm_variant s5p64x0_variant = {
.bits = 32,
- .div_base = 0,
.has_tint_cstat = true,
- .tclk_mask = 0,
};
static const struct samsung_pwm_variant s5pc100_variant = {
.bits = 32,
- .div_base = 0,
.has_tint_cstat = true,
.tclk_mask = BIT(5),
};
If I saw the resulting code, I'd wonder about the missing assignments
in these three structs. So IMHO the status quo is better even though it
is more verbose.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists