Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1666757
| From | Dawid Kurek <dawikur@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] drm: Reduce scope of 'state' variable |
| Date | 2017-06-15 16:30 +0200 |
| Message-ID | <tSDWy-3yH-13@gated-at.bofh.it> (permalink) |
| References | <tSAvE-1ng-13@gated-at.bofh.it> <tSAYF-1Mg-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 15/06/17, Jani Nikula wrote:
> 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.
I saw combining declaration and initialization is quite common, i.e. in
drm_atomic file. Personally, I also prefer those in one statement. But yes, it
looks cleaner here, in two lines.
v2 sent :)
Thanks,
Dawid
>
> BR,
> Jani.
>
> > +
> > if (!state)
> > return NULL;
> > if (drm_atomic_state_init(dev, state) < 0) {
>
> --
> Jani Nikula, Intel Open Source Technology Center
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] drm: Reduce scope of 'state' variable Dawid Kurek <dawikur@gmail.com> - 2017-06-15 12:50 +0200
Re: [PATCH] drm: Reduce scope of 'state' variable Jani Nikula <jani.nikula@linux.intel.com> - 2017-06-15 13:20 +0200
Re: [PATCH] drm: Reduce scope of 'state' variable Dawid Kurek <dawikur@gmail.com> - 2017-06-15 16:30 +0200
Re: [PATCH] drm: Reduce scope of 'state' variable Jani Nikula <jani.nikula@linux.intel.com> - 2017-06-15 17:20 +0200
Re: [PATCH] drm: Reduce scope of 'state' variable Dawid Kurek <dawikur@gmail.com> - 2017-06-15 19:00 +0200
csiph-web