From: Jani Nikula <jani.nikula@linux.intel.com>
To: Dawid Kurek <dawikur@gmail.com>,
Daniel Vetter <daniel.vetter@intel.com>,
Sean Paul <seanpaul@chromium.org>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm: Reduce scope of 'state' variable
Date: Thu, 15 Jun 2017 14:09:07 +0300 [thread overview]
Message-ID: <871sqlzewc.fsf@intel.com> (raw)
In-Reply-To: <20170615104142.GA29276@gmail.com>
On Thu, 15 Jun 2017, Dawid Kurek <dawikur@gmail.com> wrote:
> Smaller scope reduces visibility of variable and makes usage of
> uninitialized variable less possible.
> ---
> drivers/gpu/drm/drm_atomic.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index f32506a..ea5a9a7 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -108,10 +108,11 @@ struct drm_atomic_state *
> drm_atomic_state_alloc(struct drm_device *dev)
> {
> struct drm_mode_config *config = &dev->mode_config;
> - struct drm_atomic_state *state;
>
> if (!config->funcs->atomic_state_alloc) {
> - state = kzalloc(sizeof(*state), GFP_KERNEL);
> + struct drm_atomic_state *state
> + = kzalloc(sizeof(*state), GFP_KERNEL);
Separate declaration and initialization would lead to a cleaner patch
and result.
BR,
Jani.
> +
> if (!state)
> return NULL;
> if (drm_atomic_state_init(dev, state) < 0) {
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Dawid Kurek <dawikur@gmail.com>,
Daniel Vetter <daniel.vetter@intel.com>,
Sean Paul <seanpaul@chromium.org>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm: Reduce scope of 'state' variable
Date: Thu, 15 Jun 2017 14:09:07 +0300 [thread overview]
Message-ID: <871sqlzewc.fsf@intel.com> (raw)
In-Reply-To: <20170615104142.GA29276@gmail.com>
On Thu, 15 Jun 2017, Dawid Kurek <dawikur@gmail.com> wrote:
> Smaller scope reduces visibility of variable and makes usage of
> uninitialized variable less possible.
> ---
> drivers/gpu/drm/drm_atomic.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index f32506a..ea5a9a7 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -108,10 +108,11 @@ struct drm_atomic_state *
> drm_atomic_state_alloc(struct drm_device *dev)
> {
> struct drm_mode_config *config = &dev->mode_config;
> - struct drm_atomic_state *state;
>
> if (!config->funcs->atomic_state_alloc) {
> - state = kzalloc(sizeof(*state), GFP_KERNEL);
> + struct drm_atomic_state *state
> + = kzalloc(sizeof(*state), GFP_KERNEL);
Separate declaration and initialization would lead to a cleaner patch
and result.
BR,
Jani.
> +
> if (!state)
> return NULL;
> if (drm_atomic_state_init(dev, state) < 0) {
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2017-06-15 11:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 10:41 [PATCH] drm: Reduce scope of 'state' variable Dawid Kurek
2017-06-15 10:41 ` Dawid Kurek
2017-06-15 11:09 ` Jani Nikula [this message]
2017-06-15 11:09 ` Jani Nikula
2017-06-15 14:24 ` Dawid Kurek
2017-06-15 14:24 ` Dawid Kurek
2017-06-15 15:10 ` Jani Nikula
2017-06-15 15:10 ` Jani Nikula
2017-06-15 16:56 ` Dawid Kurek
2017-06-15 16:56 ` Dawid Kurek
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=871sqlzewc.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dawikur@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanpaul@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.