Re: spi: cadence-xspi: Drop useless assignment to NULL

From: Uwe Kleine-König
Date: Tue Nov 21 2023 - 03:32:59 EST


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/ |

Attachment: signature.asc
Description: PGP signature