Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp214440imm; Wed, 11 Jul 2018 00:47:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+opN5IBCW6VoAvuKR1JA/JCwf564Yw81NbnEXYKDnlL8xXgSNq52W+8s9vbb9MjN6Bo6k X-Received: by 2002:a63:4203:: with SMTP id p3-v6mr25592120pga.184.1531295256342; Wed, 11 Jul 2018 00:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531295256; cv=none; d=google.com; s=arc-20160816; b=g5EoEmCPywm9khP96jlcOHmt+rHj3/h6cdTYAON7dxVuuPzYRefPb7ELgELvlJ+6Oo l53QhQ/ivA5rBGJONBLUQewtcuE4gjZLDV1OEPIxbTwpB8ZGmPSM7it0NDXgPgufIsLJ JKpzcbRu7Fkw4mjLmkVoxjj1FUl6FDdU1yEtJk2Xz+ojlFdV7gHEuieCk9MBE3hn8TiX lTGzl5Qzku9Ol3rPHNwoze4aFYPssSkK4x34e8/C8yCsAehuzEsp+zJY7g0BwR4pgI9H CpqCjAAQfTCFzp4eoGf3TMbM/kl5bp4+wGJtPzzCn5GmXUS5M/Kqn70quMP6f9uf9E/+ oQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=e26y09fBOcyIZSftwSDuspb6B2LEHp4bVIJqparAapY=; b=wUoKeKzy8KWpy3YCTpBdbbkp9Fj3CYEJn5vxT0xjNgWCJ/m2PUPvmJUUGEgKR4nuv+ o/dceHZO+MkUjpTQqyVm6zup5/DLMr8eQhMM7ZioNdV9ECYgIbRKizgiMSh3DfTpPmJV YEU+xZ2VMcIA57xQ2B2GVAoZDW5X5kYu6X2B1pQWFOk92mUBdFwhVQBrZpcMEtHFOgI7 W0fzn6sgPlSkeH8Q8CpEsfT6YAeVlgAdxLk/ISQqa4l98+BLou6AsKoZsvV7vsrtBPwt iowglVQm3s7lm9yZ/1vG8z4IxGgzZEjw8sqlupHRqXeww4qKgX3YNnX/qE+zWzbTPssb XuvA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi1-v6si4500672plb.399.2018.07.11.00.47.21; Wed, 11 Jul 2018 00:47: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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726637AbeGKHtY (ORCPT + 99 others); Wed, 11 Jul 2018 03:49:24 -0400 Received: from nautica.notk.org ([91.121.71.147]:47990 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbeGKHtY (ORCPT ); Wed, 11 Jul 2018 03:49:24 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id CAA6FC009; Wed, 11 Jul 2018 09:46:25 +0200 (CEST) From: Dominique Martinet To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Cc: David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dominique Martinet Subject: =?UTF-8?q?=5BPATCH=5D=20i915/intel=5Ftv=5Fget=5Fmodes=3A=20fix=20strncpy=20truncation=20warning?= Date: Wed, 11 Jul 2018 09:46:15 +0200 Message-Id: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is effectively no-op as the next line writes a nul at the final 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 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'; mode_ptr->hdisplay = hactive_s; -- 2.17.1