Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1651639imm; Thu, 12 Jul 2018 05:45:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcEQrHJ057fi8RYJqLEgKww+Yh6XEiv15l2GV5G2nRH43wMuk/aDGzhQuxmAt73lJBaJtMX X-Received: by 2002:a17:902:7248:: with SMTP id c8-v6mr2107035pll.128.1531399536663; Thu, 12 Jul 2018 05:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531399536; cv=none; d=google.com; s=arc-20160816; b=ATd+Xnrfs8+T5pzylus3TVdAO/rWLWzIRG+zo5WWrDSGw+fqYSFEQku8E72ccbdEnr xYfON50SOwCyXHO80uy8GMKcd5Jcm8hSmFAbFA9YId8be8uZWrh+szGgFvnMNS1t1aAt shSQgn3Y3KnHpiBkcgkly5QDXYsuifzQuSis9VbTnCE74OufOzMlBYwaWvLD1qhIz4sC 9T4z48HmPVYJ0jOmJv/v5hWEn775Jx9dxrobb1cquFI1BkyPkucXuPqvVCZVM0OCRQQv 0BtD0UsRt7amAZQcG6q+Rf1lHFr1rrtTBUX59zUR+M30XqXpknzCeop7pGMTQ290Nkj6 v+yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=zEjv73zWKgJcN/XZN/UYQSXJOblcljwPuPqvAm/Xbfg=; b=Wiyp3WOB6eNuRVkzEJpX/2Q6nfsJ6t5mgoK/LHCUdTyI7PNMSS/+l1aycuDJC3URGr 3fc4B/ISsNv8ezATtWqvpFZxarzjrgfSs0EeL66YaHtAMKdIXmsrARPA/JHjXeWelZ5V 7w3jaecCJ+49FGx5nJViRM7TtWTWpZJZbGT8WQem1BOMGJWOzccfwen30278tk6IIDKZ waTxy1CpSePF9oN9V+GZdt8J/pBMt/5lEItJJ1CDXSVm4tDgs+GpD7eVk0cCjuOh84x3 kszWy0eIn8fvLFbHkZNouFZwnw858n3ds2LiaExjcbMv4y2UuXpXsO+BLyD5EqHX+90V s9Jw== 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 m37-v6si21949576plg.491.2018.07.12.05.45.21; Thu, 12 Jul 2018 05:45:36 -0700 (PDT) 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 S1732410AbeGLMxb (ORCPT + 99 others); Thu, 12 Jul 2018 08:53:31 -0400 Received: from mga05.intel.com ([192.55.52.43]:11769 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbeGLMxa (ORCPT ); Thu, 12 Jul 2018 08:53:30 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2018 05:44:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,342,1526367600"; d="scan'208";a="56344047" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga008.jf.intel.com with SMTP; 12 Jul 2018 05:44:02 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 12 Jul 2018 15:44:01 +0300 Date: Thu, 12 Jul 2018 15:44:01 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Dominique Martinet Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [Intel-gfx] [PATCH] i915/intel_tv_get_modes: fix strncpy truncation warning Message-ID: <20180712124401.GZ5565@intel.com> References: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 11, 2018 at 09:46:15AM +0200, Dominique Martinet wrote: > This is effectively no-op as the next line writes a nul at the final What is "This". Please write self contained commit messages. > byte of the buffer, so copying one letter less does not change the > behaviour. > > Signed-off-by: Dominique Martinet > --- > > gcc 8 gives the following warning, which I am not sure why is treated > as error for this file, thus making me fix it: > drivers/gpu/drm/i915/intel_tv.c: In function ‘intel_tv_get_modes’: > drivers/gpu/drm/i915/intel_tv.c:1358:3: error: ‘strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation] > strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors That warning should be in the actual commit message. > > > Also, as a side note, while checking if this was already sent I stumbled > uppon this: https://lists.freedesktop.org/archives/intel-gfx/2018-July/170638.html > ([Intel-gfx] [PATCH i-g-t 6/7] Fix truncate string in the strncpy) > which replaces strncpy(dest, src, sizeof(dest)) by strncpy(dest, src, > strlen(dest))... This isn't for linux but this looks like a pretty bad > idea to me... (I'm not on the list to reply there, sorry) > > drivers/gpu/drm/i915/intel_tv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c > index b55b5c157e38..f5614d07b10d 100644 > --- a/drivers/gpu/drm/i915/intel_tv.c > +++ b/drivers/gpu/drm/i915/intel_tv.c > @@ -1355,7 +1355,7 @@ intel_tv_get_modes(struct drm_connector *connector) > mode_ptr = drm_mode_create(connector->dev); > if (!mode_ptr) > continue; > - strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN); > + strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN - 1); > mode_ptr->name[DRM_DISPLAY_MODE_LEN - 1] = '\0'; This same pattern is used all over drm. Can you go and fix them all up? One might even consider writing a cocci patch for it ;) > > mode_ptr->hdisplay = hactive_s; > -- > 2.17.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Ville Syrjälä Intel