From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to tell if a field in c struct is initialized?
Date: Fri, 8 Dec 2017 14:11:46 +0100 [thread overview]
Message-ID: <20171208131146.GA24750@kroah.com> (raw)
In-Reply-To: <CAJQX3Dx4UB06QNNtofr2Y7R=pQYQaedYcVZoiWc3A72ya5F1hw@mail.gmail.com>
On Fri, Dec 08, 2017 at 08:47:42PM +0800, Shiyao MA wrote:
> Hi,
>
> I come across this code:
> http://elixir.free-electrons.com/linux/latest/source/drivers/scsi/scsi_netlink.c#L128
>
> other fields such as .cbmutex, .bind, etc are not initialized.
>
> Since the object =cfg= is of automatic storage, I wonder how the
> kernel tells if a field is initialized or its value is just some
> random bits on the stack?
The fields are initialized to zero. It's a C specification requirement.
Hope this helps,
greg k-h
next prev parent reply other threads:[~2017-12-08 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 12:47 How to tell if a field in c struct is initialized? Shiyao MA
2017-12-08 13:11 ` Greg KH [this message]
2017-12-08 13:23 ` Shiyao MA
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=20171208131146.GA24750@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/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).