Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3851650imm; Mon, 25 Jun 2018 05:47:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVLPDjxRgO8QnO1m/OoTVPjRhvaGSwolK1yE9UXC2mj7W9VyDe5ky7ASMhk4VrZQ4sYYBn X-Received: by 2002:a62:3f11:: with SMTP id m17-v6mr9051730pfa.132.1529930832619; Mon, 25 Jun 2018 05:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529930832; cv=none; d=google.com; s=arc-20160816; b=hhOyntPsueu+TKNqXgxTyMF5qaj6LxspnsAjDOWr0ahI8hl5+9cvDGV+ac7I8HJ7ZE qmlsiGIVoTapsu5fvX3JrqU5mLPHQA4YRllwG+dH5lgypD+lcsQmhjhXaCso6IttCTgZ W69FPvOIeHzG1+MvhkCtcaKnL2kKpxX2VJMK9IMy7iRI/oeU4TFpszBoRRCEnVm7y9gW ESffUg5O4/MhtbTA8leYgLVphica+FX9leWx3Aebe3MC6qr0eJuqO7VlvVjbpzlXZxK0 w+Uk45fDv0mrsTkKO0awG6E/sUF2OlztJ9X4bkQBLXMncbCppVwAq7Y2zFYNcL92Hy0N 3Y9A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/fFwUTOq5TotVWM5uJztPWAemINo6V3+BKTxyGrVtys=; b=iLtgv/YTtqhWVWLhdJUUcPOadaODowMQnGh/Pk8jgAFR4DY4g/oCUV/sW3b8/b5VEM h5oLCxSrJK8dc2x7kVVc3gk8L8+bFZOArs1BuoPhLngUuP64Md+rgFbblTnysg0xCEk3 n3LrZkgsYFMDnjdL9X94a6BqcDHEmRriPn2KzduhFKOQGBFWaSJPgVpCD7gMLw48bfoe 0VbBSgiQUFDkLAoo9tHAWoWtOoYMsv7eUqvYXINM5K2vO1bb27EpTL2GmW1P6G8A4Rqc SdSOHWs2s6+q1O87QvEh0iwECinDveu5FeibbZmh5dnHFaNTgvjoqZrrMUaQW0QzrUlx bAhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IMpcRKln; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4-v6si7944710pgb.79.2018.06.25.05.46.58; Mon, 25 Jun 2018 05:47:12 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IMpcRKln; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755463AbeFYMqI (ORCPT + 99 others); Mon, 25 Jun 2018 08:46:08 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:43426 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755429AbeFYMqD (ORCPT ); Mon, 25 Jun 2018 08:46:03 -0400 Received: by mail-pf0-f195.google.com with SMTP id y8-v6so6392642pfm.10; Mon, 25 Jun 2018 05:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/fFwUTOq5TotVWM5uJztPWAemINo6V3+BKTxyGrVtys=; b=IMpcRKlnjG7lvrzYdDM4q4OOv3KhbIL6JSwjmN+JLjg8Y2z6CtRwOxoOEwpxqRrmAH +XWdsLkiaP+3ggwzN+ISeTPxWrW3rvxVm1cEeJ4JecfDszXEqdgmnm/9iVMyHngwYNbw XP8as88TmNyHsQdA/2Jl2b6AIdXGbvy39qJ85Z5bZjCgAGmqBSvgVq3n7byaNvWgfZjg YPMInfJP3wvzO3IYXBLW7ekkxkqvUkIJ0/ZcVlVlRsSzZdmuIqSST4rdJq+9h0G9k+Xr l6o2iZOVViIPmj3hKhOz/MaQRXb/AhOfRbgqQXN1Ucj95jx42vtZvWkUOk1xMyxIeYYh wKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/fFwUTOq5TotVWM5uJztPWAemINo6V3+BKTxyGrVtys=; b=A10Y4f9FQ84YZZUFJAM/v4aer/lxAT30pv8x3jwzJE2+EpAdtA2SHPOH2fdRjG+uo/ 1/BOWiGb8Ss/XN5KVmIaGL8pmUDZz7Sd5oj6J9xtoFDX2tzV4wk/okljIt6hXGlJuJB7 Ap6EmusqjpSEDpd9H9Kv98eVEzc817y31ZjHaqPKTpXI282q0BGYMlVbY7S7OO3sIxFx bH5PCA6K1tfAYS4wn42hN16IDjyYsyzSiCs2hj51ZSh8UVRHZS++6b/xlaq94lfYjqMi L8yXEa6A5YN4Tybn9GecQKN3lmrepXD0UF98/YoBga88NYZkpg6IQ0rDU+DKayZSp8B1 aEgw== X-Gm-Message-State: APt69E3FYDWvtx8fBoeTvMaH0k9tc5SNNTUxeK9QzSuVJUA/OSSYxLll pHTYGAcBzA65t3vr/MyamusSvWe/cco= X-Received: by 2002:a63:80c3:: with SMTP id j186-v6mr10778181pgd.426.1529930762928; Mon, 25 Jun 2018 05:46:02 -0700 (PDT) Received: from localhost (g134.124-44-9.ppp.wakwak.ne.jp. [124.44.9.134]) by smtp.gmail.com with ESMTPSA id y4-v6sm3479214pgy.18.2018.06.25.05.46.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 05:46:02 -0700 (PDT) From: Stafford Horne To: LKML Cc: Greg KH , arnd@arndb.de, Eric Biggers , linux-crypto@vger.kernel.org, Stafford Horne Subject: [PATCH v2 2/2] kobject: Fix -Wstringop-truncation warning Date: Mon, 25 Jun 2018 21:45:38 +0900 Message-Id: <20180625124538.21051-3-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180625124538.21051-1-shorne@gmail.com> References: <20180625124538.21051-1-shorne@gmail.com> 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 When compiling with GCC 9.0.0 I am seeing the following warning: In function ‘fill_kobj_path’, inlined from ‘kobject_get_path’ at lib/kobject.c:155:2: lib/kobject.c:128:3: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] strncpy(path + length, kobject_name(parent), cur); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/kobject.c: In function ‘kobject_get_path’: lib/kobject.c:125:13: note: length computed here int cur = strlen(kobject_name(parent)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is not really an issue since the buffer we are writing to is pre-zero'd and we have already allocated the buffer based on the calculated strlen size and accounted for the terminating '\0'. Just use memcpy() instead. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Eric Biggers Signed-off-by: Stafford Horne --- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kobject.c b/lib/kobject.c index 18989b5b3b56..e876957743c8 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -125,7 +125,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length) int cur = strlen(kobject_name(parent)); /* back up enough to print this name with '/' */ length -= cur; - strncpy(path + length, kobject_name(parent), cur); + memcpy(path + length, kobject_name(parent), cur); *(path + --length) = '/'; } -- 2.17.0