Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1666796

Re: [PATCH] drm: Reduce scope of 'state' variable

From Jani Nikula <jani.nikula@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] drm: Reduce scope of 'state' variable
Date 2017-06-15 17:20 +0200
Message-ID <tSEIW-46h-19@gated-at.bofh.it> (permalink)
References <tSAvE-1ng-13@gated-at.bofh.it> <tSAYF-1Mg-9@gated-at.bofh.it> <tSDWy-3yH-13@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


On Thu, 15 Jun 2017, Dawid Kurek <dawikur@gmail.com> wrote:
> On 15/06/17, Jani Nikula wrote:
>> 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.

I'd say the rule of thumb is that combined declaration and
initialization is fine if the initialization is trivial, in particular
can never fail. If you need to check the return value, like in this
case, I'd prefer separate initialization.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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