Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752204AbdFOLJM (ORCPT ); Thu, 15 Jun 2017 07:09:12 -0400 Received: from mga01.intel.com ([192.55.52.88]:56848 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751016AbdFOLJL (ORCPT ); Thu, 15 Jun 2017 07:09:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,343,1493708400"; d="scan'208";a="868239312" From: Jani Nikula To: Dawid Kurek , Daniel Vetter , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm: Reduce scope of 'state' variable In-Reply-To: <20170615104142.GA29276@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20170615104142.GA29276@gmail.com> Date: Thu, 15 Jun 2017 14:09:07 +0300 Message-ID: <871sqlzewc.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1065 Lines: 35 On Thu, 15 Jun 2017, Dawid Kurek 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