Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10782859imu; Thu, 6 Dec 2018 06:45:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vdcnm6RMr6aDbR4M0DgxfLe8NDhe4WasCds6EK/XrnFo57uRKw3WjUqUmCOYibrR+tnkGn X-Received: by 2002:a62:1043:: with SMTP id y64mr29248150pfi.78.1544107534787; Thu, 06 Dec 2018 06:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107534; cv=none; d=google.com; s=arc-20160816; b=KN/ODLlMwxG0uU/3hS3W8tOrlfKPcigQlcUzuTqidN701bRTT2ouvq7ljg6tA8npDQ w07oRihJQ6bc0O2d//ED8jkJGgudAu9zSbl1EBCKSLGFd8JoieMHACYvkhAn8+xqodRa nUqUnGfZFjTQG5fnQDIXI+y1IGkuv3zB028vKDg+kc629BrqauQmv2ivgFQUBeTHniOi 3BD+yGyHuwuHtV2n29/I77Fc75+UjOa9FgEReJmoHm/iGUfMf8seI0rINwe3KvPDleo5 71I7gBeFiN4z9rS8dB23vi1ArgaT5gHQWcoruZvihUQmp4jM9QCeKF6xbRZhxA9VuiI4 Tmxg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zxsxOvnJz3i4iM90WwZBJUM5D5YZpFTaCuRdiRWDpG8=; b=eEy97xkcWEgjh5QjhaizZnxoFCsybtqPOIf79DorTMUMDPMQexEXqKskj1bnpPuJFN Z1IxN8DU7A0IJsyh16NOa2QQSHKXgtZdTpZjOd6QRaxZqPY/q1443Y2oiUJO3YIKwV/b v4FiiOxiAN01jNTRMpFbhBqOddf80VLVKZnF5fYa7taDnCBh4lbLKWYKd7OcoweCi6s9 NbzHudtJT1+M1UFPVu+TuiLmikFz0AWmLuSB/oGOH0kRKWSwh91UBtuA8uZ6W57YLdgb NaL0HTvWuPUe4pMHDwA++poPznHypOL05ZLywr1McXgBCAOyHAzWoILJS3WSj2lwF4bP iGOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ny7vxlK7; 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 n24si375342pgv.119.2018.12.06.06.45.07; Thu, 06 Dec 2018 06:45:34 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ny7vxlK7; 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 S1730430AbeLFOmN (ORCPT + 99 others); Thu, 6 Dec 2018 09:42:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:46454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730401AbeLFOmL (ORCPT ); Thu, 6 Dec 2018 09:42:11 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02B4120661; Thu, 6 Dec 2018 14:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107330; bh=QPpV8wvYoHUnVs+ZJdNwAHNa/C7/sr/dvN/kGaBO7j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ny7vxlK7jjUb9EpTbj3W8FwUCkn4IDjxN2Jg2eUeBBcAncEGnVkLfNZvphw3maHoD RAMrG/SpQVZPz6L2mMjgiuXVh/1xuiBC6CNTnq6hRu5t1T9xqU2MB/juQTmeANJw/V S+s8GIVm8zAyR89dZ/iTQPsfGszAXEZxwE8TQy+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds Subject: [PATCH 4.14 06/55] unifdef: use memcpy instead of strncpy Date: Thu, 6 Dec 2018 15:38:40 +0100 Message-Id: <20181206143002.090898598@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143001.749982936@linuxfoundation.org> References: <20181206143001.749982936@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit 38c7b224ce22c25fed04007839edf974bd13439d upstream. New versions of gcc reasonably warn about the odd pattern of strncpy(p, q, strlen(q)); which really doesn't make sense: the strncpy() ends up being just a slow and odd way to write memcpy() in this case. There was a comment about _why_ the code used strncpy - to avoid the terminating NUL byte, but memcpy does the same and avoids the warning. Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- scripts/unifdef.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/scripts/unifdef.c +++ b/scripts/unifdef.c @@ -395,7 +395,7 @@ usage(void) * When we have processed a group that starts off with a known-false * #if/#elif sequence (which has therefore been deleted) followed by a * #elif that we don't understand and therefore must keep, we edit the - * latter into a #if to keep the nesting correct. We use strncpy() to + * latter into a #if to keep the nesting correct. We use memcpy() to * overwrite the 4 byte token "elif" with "if " without a '\0' byte. * * When we find a true #elif in a group, the following block will @@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ign static void Itrue (void) { Ftrue(); ignoreon(); } static void Ifalse(void) { Ffalse(); ignoreon(); } /* modify this line */ -static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); } +static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); } static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); } static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); } static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }