lkml.org 
[lkml]   [2023]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: 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/ |[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2023-11-21 09:33    [W:0.032 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site