linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: kernel@pengutronix.de, kernel-janitors@vger.kernel.org,
	Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	cocci@inria.fr, Amit Dhingra <mechanicalamit@gmail.com>
Subject: Re: spi: cadence-xspi: Drop useless assignment to NULL
Date: Tue, 21 Nov 2023 09:32:46 +0100	[thread overview]
Message-ID: <20231121083246.wg5qtej6cll3snlg@pengutronix.de> (raw)
In-Reply-To: <3e4c0c06-9681-43df-be12-b2bbc599fdfb@web.de>

[-- Attachment #1: Type: text/plain, Size: 1756 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2023-11-21  8:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231105143932.3722920-2-u.kleine-koenig@pengutronix.de>
     [not found] ` <233689d7-9409-406b-9383-49f10cd29336@web.de>
2023-11-20 22:18   ` spi: cadence-xspi: Drop useless assignment to NULL Amit Dhingra
     [not found]     ` <53db2c8f-7b9b-47f7-89ba-d78584c12d7b@web.de>
2023-11-21  7:57       ` Uwe Kleine-König
     [not found]         ` <3e4c0c06-9681-43df-be12-b2bbc599fdfb@web.de>
2023-11-21  8:32           ` Uwe Kleine-König [this message]
2023-11-22 19:50             ` Amit Dhingra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231121083246.wg5qtej6cll3snlg@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=Markus.Elfring@web.de \
    --cc=broonie@kernel.org \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mechanicalamit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).