Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp925935imu; Tue, 11 Dec 2018 09:39:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/VuC3lkorYSpOk42ycauDYsIRgLmekqIzCFlJsdnrlWy2QG7WF//zEaNBV0V8GAWJjeeycr X-Received: by 2002:a62:47d9:: with SMTP id p86mr16742894pfi.95.1544549956917; Tue, 11 Dec 2018 09:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544549956; cv=none; d=google.com; s=arc-20160816; b=Xo962ngeWb8Lcx0Hb+i4SE4hkq4qNJCI6R6uLLWBO0+iP/t3gH+/f79hAmWqnZIm+0 h2UHkxkGf5qLz+TOg/nDzhyaRuMOpkc8KvnNcbUMBh4i+4gbGpS1jgnh+HnHO7P2QYrC NFQA+gIjKmvTFOzpuhm7U06UYhAdEDfHZ+e4D4IkNFIx11Y3CcOvgg07P6Vu3y/95/nq g/yp8HSg+RD5FnATwgNik1/FuGVhgl7PumdD9R36SnIWDYxJ9OfETVFSRSichBlTVoSO 2CAYD+4l2yehDhKtGi6lnWpuUJt0dwUaZkjcM4cB+QT/XfJLQs5aYDq6RbGi0F/KGqKs xHSA== 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=q+3BhVnD8PpxXhOYZ6RNbG0O0M+JkDbwIRPULunw2t8=; b=mVj6UYnFGupgaOWDFgbOvyULNOJfVS9CCm62XGJwcNNB5wEgWK3pU0CW087mNbmSXc 9Xpc5gkoafdgHwtmZJvwbN1eKWn/qD6U9lC6CbeaG5uazoiqbTdbB+X4EDF0Ws6i/L/u IAUPhD0MOSOyjQ8s47S87oK07p4Q5wB9ItIqjCA3wBPqnOPGUvwUeva3mWELCMAz1gR5 5DgBwH0tMOZOSQbi2zYIi9hBCyHzTnR2nfsZp4a+6tHp5YUCvkrTNK2XBSIZXpduq/pW 1xZHohshfr8weCymsCwAu1n3mAWu4zs2yby/6FMb/PYJWcttUmgLYAE9qJomY8fSfF7y Di9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IfJmp9wP; 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 b12si12699109plx.159.2018.12.11.09.39.01; Tue, 11 Dec 2018 09:39:16 -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=IfJmp9wP; 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 S1728481AbeLKQTt (ORCPT + 99 others); Tue, 11 Dec 2018 11:19:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:33978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbeLKPpc (ORCPT ); Tue, 11 Dec 2018 10:45:32 -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 D6AF421479; Tue, 11 Dec 2018 15:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543132; bh=m0Yq7vsFwLm5rcnspiysqmb6t2Jgm3tezryuCyNRuQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfJmp9wPXguCa7M8rC7KUB5ywKGZm7ityhG3SsJ9M+JRJf1p97J/HfHdKoTHlqoRp rAIwLvPFbUBCz3stlAyks/6f+Hc7Ma26UCRvj5P/P/50VWZwJz1Akxtis2m4jMIK8r MsU6un/VxrbqAfNVbfibRTdvwlCPTaju7Fx0tqCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds Subject: [PATCH 4.4 25/91] unifdef: use memcpy instead of strncpy Date: Tue, 11 Dec 2018 16:40:44 +0100 Message-Id: <20181211151607.816589545@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@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.4-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); }