Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2808119pxb; Mon, 18 Oct 2021 02:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6ZCvnPAvJv0aO5Lt0tR4Dc9iuU1t6nr/E5+R9ciKGoXnl/BS4IpLVALpaD3d+3j1u+FZ4 X-Received: by 2002:a17:90a:4306:: with SMTP id q6mr32461503pjg.17.1634548442769; Mon, 18 Oct 2021 02:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634548442; cv=none; d=google.com; s=arc-20160816; b=cO+OuI3dFV2U92r0WBS7fD6IDOIT2UEIKzLrvIJDrQ/+Mq5fjQ88GStA9cnVRhPObh b0/8KqTpQzJ1y6Em9BEHBPFcrtaz6s9t/svgEeSjFqWjj7SkmpbmGFU8HJmBfioagorl SwVmpva/j9N7RLZJXmoDPHMhxxxw/WKqhtKqvJlQ1xR4BC6ggGyc511eYgt6uKddOQpT FIMxBzEe7a04doFlWkoRzMCe/LbjDYn0gbcqPx3xCMxw3kUGrqXK2lM1VWGmTwwDcWe4 N2BMIcmoCgjqDaBbd1RPIOJZ+jKnaLUCIbk1ofd+fpsYNy+ZoODYnUd0TR4gCElieb2b txhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=svjhIv5/61yduA1q+FUTcT66Eu7xKaqfh8rAwB49ssI=; b=JhuHp1aq0dfx2OlSFrYdwOwIU19dPBEcruboei7Mi7ZE+g0AHp9jaDN0yIErFSHBRM J2C0C+6l6Ki9BwEnq7wlDQV75AFQCKnU1xKWXvfE4+lt596t4bgkAPlUl4YzfAn/Egf8 lXbKrY8I9b6XkyZDIziNEusqRpj+ycEAQZZ3lJUoAn8L6oTHV0IUspwG+X6NKwLt6CXK odkPkdT5zzoVj6Cl0YdO3n1IG15MLBlNZq7yFHmo4s6mW3N5DR7+OlHCg4XDbXpXxopq YmYj/U4forVbyZk/AS/oMRJNgq+1wrgmy0RfAfzzD4w0GK8IIFKm0Pvmt7OhWkpqAKnY 9Pzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si19356247pgj.320.2021.10.18.02.13.50; Mon, 18 Oct 2021 02:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbhJRJOd (ORCPT + 99 others); Mon, 18 Oct 2021 05:14:33 -0400 Received: from mga17.intel.com ([192.55.52.151]:49450 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231528AbhJRJOS (ORCPT ); Mon, 18 Oct 2021 05:14:18 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="209001452" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="209001452" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 02:12:06 -0700 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="493509143" Received: from foboril-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.44.188]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 02:12:01 -0700 From: Jani Nikula To: luo penghao Cc: Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Stephen Rothwell , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, luo penghao , Zeal Robot , "Deak\, Imre" Subject: Re: [PATCH linux-next] drm/i915/display: Remove unused variable in the for loop. In-Reply-To: <20211018084449.852251-1-luo.penghao@zte.com.cn> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20211018084449.852251-1-luo.penghao@zte.com.cn> Date: Mon, 18 Oct 2021 12:11:58 +0300 Message-ID: <87k0iau275.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Oct 2021, luo penghao wrote: > Variable is not used in the loop, and its assignment is redundant too. > So it should be deleted. > > The clang_analyzer complains as follows: > > drivers/gpu/drm/i915/display/intel_fb.c:1018:3 warning: > > Value stored to 'cpp' is never read. > > Reported-by: Zeal Robot > Signed-off-by: luo penghao > --- > drivers/gpu/drm/i915/display/intel_fb.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c > index fa1f375..b9b6a7a 100644 > --- a/drivers/gpu/drm/i915/display/intel_fb.c > +++ b/drivers/gpu/drm/i915/display/intel_fb.c > @@ -998,7 +998,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer * > for (i = 0; i < num_planes; i++) { > struct fb_plane_view_dims view_dims; > unsigned int width, height; > - unsigned int cpp, size; > + unsigned int size; > u32 offset; > int x, y; > int ret; > @@ -1015,7 +1015,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer * > return -EINVAL; > } > > - cpp = fb->base.format->cpp[i]; > + fb->base.format->cpp[i]; Thanks for the report. However, this "fix" isn't any better than having the unused variable. It's obviously wrong. It would be useful to dig into the history of the function, and figure out when and why the variable became unused, and whether that caused an actual bug or whether this was just leftovers from some refactoring. So that's what I did. Some git blame and git log -p revealed commit d3c5e10b6059 ("drm/i915/intel_fb: Factor out convert_plane_offset_to_xy()") that moved the check that used the cpp variable to a separate function, and the local variable and the line above became unused and useless. That's the actually helpful part. It's easy to see and verify that the right fix is to just remove the line completely. BR, Jani. > intel_fb_plane_dims(fb, i, &width, &height); > > ret = convert_plane_offset_to_xy(fb, i, width, &x, &y); -- Jani Nikula, Intel Open Source Graphics Center