From patchwork Mon Aug 20 16:55:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Meyering X-Patchwork-Id: 1350391 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AFDA7DFB6E for ; Mon, 20 Aug 2012 17:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753961Ab2HTR33 (ORCPT ); Mon, 20 Aug 2012 13:29:29 -0400 Received: from mx.meyering.net ([88.168.87.75]:44784 "EHLO hx.meyering.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751259Ab2HTR3S (ORCPT ); Mon, 20 Aug 2012 13:29:18 -0400 X-Greylist: delayed 1784 seconds by postgrey-1.27 at vger.kernel.org; Mon, 20 Aug 2012 13:29:17 EDT Received: from hx.meyering.net (hx.meyering.net [127.0.0.1]) by hx.meyering.net (8.14.5/8.14.5) with ESMTP id q7KGtrQP030294; Mon, 20 Aug 2012 18:55:53 +0200 Received: (from meyering@localhost) by hx.meyering.net (8.14.5/8.14.5/Submit) id q7KGtqdE030293; Mon, 20 Aug 2012 18:55:52 +0200 From: Jim Meyering To: linux-kernel@vger.kernel.org Cc: Jim Meyering , Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH] ACPI: remove unwarranted use of strncpy Date: Mon, 20 Aug 2012 18:55:20 +0200 Message-Id: <1345481724-30108-2-git-send-email-jim@meyering.net> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1345481724-30108-1-git-send-email-jim@meyering.net> References: <1345481724-30108-1-git-send-email-jim@meyering.net> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Jim Meyering strncpy is best avoided in general. Here, using strcpy would have been clearer and semantically equivalent, but we can do better still by removing it: i.e., use kstrdup in place of kzalloc+strncpy. Signed-off-by: Jim Meyering --- drivers/acpi/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 7c3f98b..20cc627 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -674,10 +674,9 @@ void acpi_irq_stats_init(void) else sprintf(buffer, "bug%02X", i); - name = kzalloc(strlen(buffer) + 1, GFP_KERNEL); + name = kstrdup(buffer, GFP_KERNEL); if (name == NULL) goto fail; - strncpy(name, buffer, strlen(buffer) + 1); sysfs_attr_init(&counter_attrs[i].attr); counter_attrs[i].attr.name = name;