public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH v2] driver core: Explicitly initialize struct member @data.have_async in __device_attach()
Date: Fri, 23 Aug 2024 08:55:41 -0700	[thread overview]
Message-ID: <Zsiw_cUgoXEcY7io@google.com> (raw)
In-Reply-To: <20240823-fix_have_async-v2-1-ed1039527365@quicinc.com>

On Fri, Aug 23, 2024 at 08:00:14PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> __device_attach() relies on compiler to implicitly initialize struct
> member @data.have_async to avoid the member is used before initialization
> but readers may not understand that, solved by explicitly initializing
> @data.have_async as well as existing @data.want_async.

I do not believe this is needed. We require kernel developers be
familiar with the language of choice for the kernel.

We have a ton of partial or empty structure initializers in the kernel.
If we count only empty non-static ones I see:

dtor@dtor-ws:~/kernel/work $ git grep '= \?{ \?};' | grep -v static | wc -l
5707

Rough count of partial initializers is (might be over eager and some
of them could be full ones, on the other hand it does not count
initializers that span multiple lines and start with opening brace
only):

dtor@dtor-ws:~/kernel/work $ git grep '= \?{ \..* };' | grep -v static | wc -l
1150

Are you planning to go through all of them and add complete
initializers? And keep adjusting them when structures will get extended?
For what gain?

There was no readers confusion, you wrote a tool for C static analysis
that did not follow C standard and gave you a false warning. Please fix
your tool instead.

> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> Changes in v2:
> - Remove both fix and stable tag
> - Correct both title and commit messages
> - Link to v1: https://lore.kernel.org/r/20240823-fix_have_async-v1-1-43a354b6614b@quicinc.com
> ---
>  drivers/base/dd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 9b745ba54de1..b0c44b0846aa 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -1021,6 +1021,7 @@ static int __device_attach(struct device *dev, bool allow_async)
>  			.dev = dev,
>  			.check_async = allow_async,
>  			.want_async = false,
> +			.have_async = false,
>  		};
>  
>  		if (dev->parent)
> 
> ---
> base-commit: 87ee9981d1f86ee9b1623a46c7f9e4ac24461fe4
> change-id: 20240823-fix_have_async-3a135618d91b
> 
> Best regards,
> -- 
> Zijun Hu <quic_zijuhu@quicinc.com>
> 

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-08-23 15:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 12:00 [PATCH v2] driver core: Explicitly initialize struct member @data.have_async in __device_attach() Zijun Hu
2024-08-23 15:55 ` Dmitry Torokhov [this message]
2024-08-23 21:12   ` Zijun Hu

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=Zsiw_cUgoXEcY7io@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=zijun_hu@icloud.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