Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241744imm; Thu, 12 Jul 2018 18:27:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf+25C69E8QozSm6Uo+Vh3pTfSrn3mmSqg2o3XgtYPLRHgTT6tU22R6Xdaoyoq1XIXEtefE X-Received: by 2002:a62:dc8f:: with SMTP id c15-v6mr4790502pfl.155.1531445229637; Thu, 12 Jul 2018 18:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445229; cv=none; d=google.com; s=arc-20160816; b=j1rSv1EJofx90x3bQ1i56AccsbC5as5WrVdCYOWYTEHZHzVo7zp1xLFTOtcTqyTzNH XIh7ZBTUovvyOP321FOdUCfE7PWmPmlRsyK4lHFP6r/XZNuWjJTnLZeCmcrRJiTa+P/r pPzb+ciEc4JIdUQLlnPPxX+CfewoD4Ik4G8CPhfFw19eRrxAs5MCV70uO12rGgKQGc32 7Q2DXoZ31CTLSGMPjosU2XZa4ya+UCFJa0/PG9W0nUqRsJqCwINX3hTgEzE5RnZCdPy0 +eNY9dFgD8Hf2fHc0ffJHMWU6zqjmZDLebmL3jKohXo4ekT3L1lDHmOIZNR2vhi44lIH u8uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:arc-authentication-results; bh=3wHcczPvVPY9MmP/wobSjAXhRvluC9dXArbGtN6sb+A=; b=cl8uJSeEb/3rhZ+TSjrhzfHzVa4D4lDMcXZeiAuEnm1XY5DNI4m81inGEBpZrrTrrs X1sIynEBjDYu6A0CgeWh8qQm0kBdxMccYEDT8/Z4OikC4OJ9ofvxiMO8HnTO6Eem9D3r AD7NzDv0iZwqdEOFM8rbtQ479mEdbxwV6V7yps/ChhSFi565wfv+3GSvrI5QK7SYs9WJ hQnmxSnrVYYcjhUvM7JIZDThG+fjx/E6AKBRDkFOzh1aJi9Za2pWIjUcBV6MBRmg1kQA pZiNdfcrb+mnlpkOOoMTjvcCjq1u7bVX9O//NDKmph8R/ECIaxFtGgLkQeS/pbCZ+qgY bBWA== 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 s10-v6si21337218pgv.47.2018.07.12.18.26.54; Thu, 12 Jul 2018 18:27:09 -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 S2388116AbeGMBiI (ORCPT + 99 others); Thu, 12 Jul 2018 21:38:08 -0400 Received: from nautica.notk.org ([91.121.71.147]:43025 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBiH (ORCPT ); Thu, 12 Jul 2018 21:38:07 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id C30DBC026; Fri, 13 Jul 2018 03:25:54 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/18] test_power: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:53 +0200 Message-Id: <1531445153-19647-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/power/supply/test_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c index 57246cdbd042..64adf630f64f 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -297,8 +297,7 @@ static int map_get_value(struct battery_property_map *map, const char *key, char buf[MAX_KEYLENGTH]; int cr; - strncpy(buf, key, MAX_KEYLENGTH); - buf[MAX_KEYLENGTH-1] = '\0'; + strlcpy(buf, key, MAX_KEYLENGTH); cr = strnlen(buf, MAX_KEYLENGTH) - 1; if (cr < 0) -- 2.17.1