From: David Laight <David.Laight@ACULAB.COM>
To: 'Greg KH' <gregkh@linuxfoundation.org>,
Alex Deucher <alexdeucher@gmail.com>
Cc: "Deepak R Varma" <mh12gx2825@gmail.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@linux.ie>,
"Daniel Vetter" <daniel@ffwll.ch>,
"amd-gfx list" <amd-gfx@lists.freedesktop.org>,
"Maling list - DRI developers" <dri-devel@lists.freedesktop.org>,
LKML <linux-kernel@vger.kernel.org>,
"Melissa Wen" <melissa.srw@gmail.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>
Subject: RE: [PATCH] drm/amdgpu: do not initialise global variables to 0 or NULL
Date: Mon, 2 Nov 2020 22:30:45 +0000 [thread overview]
Message-ID: <d415d3297e1e4475adb4e1093fea5aca@AcuMS.aculab.com> (raw)
In-Reply-To: <20201102201040.GA2433494@kroah.com>
From: Greg KH
> Sent: 02 November 2020 20:11
>
> On Mon, Nov 02, 2020 at 02:43:45PM -0500, Alex Deucher wrote:
> > On Mon, Nov 2, 2020 at 1:42 PM Deepak R Varma <mh12gx2825@gmail.com> wrote:
> > >
> > > Initializing global variable to 0 or NULL is not necessary and should
> > > be avoided. Issue reported by checkpatch script as:
> > > ERROR: do not initialise globals to 0 (or NULL).
> >
> > I agree that this is technically correct, but a lot of people don't
> > seem to know that so we get a lot of comments about this code for the
> > variables that are not explicitly set. Seems less confusing to
> > initialize them even if it not necessary. I don't have a particularly
> > strong opinion on it however.
>
> The kernel coding style is to do it this way. You even save space and
> time by doing it as well :)
Uninitialised globals end up as 'named common' (variables that are
their own code section - from FORTRAN) until the final link puts
them into the .bss.
Globals initialised to 0 go into the .bss of the object file
being created.
So both end up in the final .bss.
If the code goes into a module you aren't allowed 'common' data
in a module to every global must be initialised.
I'm surprised checkpatch complains.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2020-11-02 22:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-02 18:41 [PATCH] drm/amdgpu: do not initialise global variables to 0 or NULL Deepak R Varma
2020-11-02 19:43 ` Alex Deucher
2020-11-02 20:06 ` Christian König
2020-11-03 6:53 ` Greg KH
2020-11-02 20:48 ` Christian König
2020-11-03 7:53 ` Greg KH
2020-11-03 8:23 ` Christian König
2020-11-03 14:50 ` Deucher, Alexander
2020-11-03 15:34 ` Greg KH
2020-11-02 20:10 ` Greg KH
2020-11-02 22:30 ` David Laight [this message]
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=d415d3297e1e4475adb4e1093fea5aca@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=melissa.srw@gmail.com \
--cc=mh12gx2825@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