Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1474257ybl; Thu, 5 Dec 2019 01:57:32 -0800 (PST) X-Google-Smtp-Source: APXvYqz6wRi+B204Pro2zqVen6IKHbm8x/XO4LpUT4QAY2Ja+ES/iZ1ipJiRvaluui3Gs2/3L8S+ X-Received: by 2002:a05:6808:14d:: with SMTP id h13mr6650649oie.58.1575539852225; Thu, 05 Dec 2019 01:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575539852; cv=none; d=google.com; s=arc-20160816; b=RdR+jODZHeOjXxim6QWHosvlACzsn0pvQ8f37akJ/lIL391NYMCG/OmrcZAs7ElmJi s7WSOS4rN/X6r2KrRaAa3oOkXy0769VJ2npsTeMNnJxUXoYbfvWAql3hREDu3XLRyU4r SbJMeGNT+a9y7o2DtOdZh77GG0kFZiwUc63aFLBlkEkoKeFRp4QChPsW68BC8L03eICW SpEuXm9CAy9MoleeLfNnpL3dSbTiEVyGHRw+6dVigNf13Zrjnyo9Lx0gGAjqU5quUekv vpDxsrwjWBbDlB+gMVG8bNUiQoKx1Xw703qahimv9O6v12hsPD9Ig5PXqMu6yCdVfq66 DI+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=m5ksx93KVNuEAISmJgPzLQTGQ8QdSb3W3CyhzS4/DDQ=; b=BNu7YIFCrErC8g7al9zlVR7Rcavh0vbWBw8XTDIDyPha1Zs/3edjrrnYaAmNzhvHmK njanqPa0NAJdp1QqqH1SvBgzXxM/6UoBwNhTmUHUxCX9ZfhlZ7xlUfBbril+kztbY4Q6 nVNp7ltFTi3jkqOkJ7PYEPwG2h6d9+iipn4Jl2bGqtkkONem0+RgYMl0tQi4yvNHbUFm cSyOpjxkj85qcOhlAtbBC+oHCtRtF3AiniJZCzamkXhOyDFAcw+SZFktZlbHq6TThI+1 koWHPu0mM5sjwBpiNtmc5bKAnUy9MWMcy92Kf6o9DYdndhL0uwjkNk1c+/AjI3+FSlsd 1CSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r21si4420098otd.276.2019.12.05.01.57.20; Thu, 05 Dec 2019 01:57:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729285AbfLEJzz (ORCPT + 99 others); Thu, 5 Dec 2019 04:55:55 -0500 Received: from mga06.intel.com ([134.134.136.31]:20429 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbfLEJzz (ORCPT ); Thu, 5 Dec 2019 04:55:55 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 01:55:54 -0800 X-IronPort-AV: E=Sophos;i="5.69,281,1571727600"; d="scan'208";a="205719543" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.161]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 01:55:51 -0800 From: Jani Nikula To: Benjamin GAIGNARD , Thomas Zimmermann , "maarten.lankhorst\@linux.intel.com" , "mripard\@kernel.org" , "sean\@poorly.run" , "airlied\@linux.ie" , "daniel\@ffwll.ch" Cc: "linux-kernel\@vger.kernel.org" , "dri-devel\@lists.freedesktop.org" Subject: Re: [PATCH] drm/modes: remove unused variables In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20191119134706.10893-1-benjamin.gaignard@st.com> <8056f838-3ebf-26db-f5be-3e78d61aa512@suse.de> Date: Thu, 05 Dec 2019 11:55:48 +0200 Message-ID: <87tv6fgkpn.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 04 Dec 2019, Benjamin GAIGNARD wrote: > On 12/4/19 10:35 AM, Thomas Zimmermann wrote: >> Hi >> >> Am 19.11.19 um 14:47 schrieb Benjamin Gaignard: >>> When compiling with W=1 few warnings about unused variables show up. >>> This patch removes all the involved variables. >>> >>> Signed-off-by: Benjamin Gaignard >>> --- >>> drivers/gpu/drm/drm_modes.c | 22 +++------------------- >>> 1 file changed, 3 insertions(+), 19 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c >>> index 88232698d7a0..aca901aff042 100644 >>> --- a/drivers/gpu/drm/drm_modes.c >>> +++ b/drivers/gpu/drm/drm_modes.c >>> @@ -233,7 +233,7 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, >>> /* 3) Nominal HSync width (% of line period) - default 8 */ >>> #define CVT_HSYNC_PERCENTAGE 8 >>> unsigned int hblank_percentage; >>> - int vsyncandback_porch, vback_porch, hblank; >>> + int vsyncandback_porch, hblank; >>> >>> /* estimated the horizontal period */ >>> tmp1 = HV_FACTOR * 1000000 - >>> @@ -249,7 +249,6 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, >>> else >>> vsyncandback_porch = tmp1; >>> /* 10. Find number of lines in back porch */ >>> - vback_porch = vsyncandback_porch - vsync; >>> drm_mode->vtotal = vdisplay_rnd + 2 * vmargin + >>> vsyncandback_porch + CVT_MIN_V_PORCH; >>> /* 5) Definition of Horizontal blanking time limitation */ >>> @@ -386,9 +385,8 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay, >>> int top_margin, bottom_margin; >>> int interlace; >>> unsigned int hfreq_est; >>> - int vsync_plus_bp, vback_porch; >>> - unsigned int vtotal_lines, vfieldrate_est, hperiod; >>> - unsigned int vfield_rate, vframe_rate; >>> + int vsync_plus_bp; >>> + unsigned int vtotal_lines; >>> int left_margin, right_margin; >>> unsigned int total_active_pixels, ideal_duty_cycle; >>> unsigned int hblank, total_pixels, pixel_freq; >>> @@ -451,23 +449,9 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay, >>> /* [V SYNC+BP] = RINT(([MIN VSYNC+BP] * hfreq_est / 1000000)) */ >>> vsync_plus_bp = MIN_VSYNC_PLUS_BP * hfreq_est / 1000; >>> vsync_plus_bp = (vsync_plus_bp + 500) / 1000; >>> - /* 9. Find the number of lines in V back porch alone: */ >>> - vback_porch = vsync_plus_bp - V_SYNC_RQD; >>> /* 10. Find the total number of lines in Vertical field period: */ >>> vtotal_lines = vdisplay_rnd + top_margin + bottom_margin + >>> vsync_plus_bp + GTF_MIN_V_PORCH; >>> - /* 11. Estimate the Vertical field frequency: */ >>> - vfieldrate_est = hfreq_est / vtotal_lines; >>> - /* 12. Find the actual horizontal period: */ >>> - hperiod = 1000000 / (vfieldrate_rqd * vtotal_lines); >>> - >>> - /* 13. Find the actual Vertical field frequency: */ >>> - vfield_rate = hfreq_est / vtotal_lines; >>> - /* 14. Find the Vertical frame frequency: */ >>> - if (interlaced) >>> - vframe_rate = vfield_rate / 2; >>> - else >>> - vframe_rate = vfield_rate; >> The amount of unused code is quite large, which makes me wonder if >> there's something missing below where these variables are supposed to be >> used. >> >> If these variables can be removed, comments should mention that steps 9 >> and 11 to 14 are being left out. After all, the function is fairly >> explicit about implementing the GTF algorithm step by step. >> >> Best regards >> Thomas > > If the goal is to keep all the steps then I could prefix all problematic > variables with __maybe_unused macro. The effect is the same; it hides a potential bug that should be analyzed and fixed. If you have the time, please look at the code and figure out what it's supposed to do, and why isn't it using the information. Look at git blame and log, was it always so, or did something change? The warnings are about potential bugs. The objective or end goal is to fix the bugs, not to silence the warnings. BR, Jani. > > Benjamin > >> >>> /* 15. Find number of pixels in left margin: */ >>> if (margins) >>> left_margin = (hdisplay_rnd * GTF_MARGIN_PERCENTAGE + 500) / >>> > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Jani Nikula, Intel Open Source Graphics Center