Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp167832rdg; Tue, 10 Oct 2023 07:12:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHI7GxUj2yecCaD+SuZj5WPz8IdDFqv/7Zs6hjCUsXaVWbAUGDt2Ktj1cS5Fp9ZZ3EP5jF3 X-Received: by 2002:a17:90a:bc0b:b0:274:95f:d203 with SMTP id w11-20020a17090abc0b00b00274095fd203mr15243769pjr.47.1696947126204; Tue, 10 Oct 2023 07:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696947126; cv=none; d=google.com; s=arc-20160816; b=KoTfIpkdHcvgsxwE/RQ0vvyCgbXYb4s3AmIXw7leVLmVr4i6w2rRQem4qwZLHYPzyT EULj+goQ2SvAI6toYIoCY5GEvaSgTnkczHfHpeHHiOcz64s5pJzWtjxu9wAPZaPXiEzF yffnC2BkqJKkfh9Gd9+gOxaQ8nk0D94HKy/o6Wrg8gt7VOT36/MqN0YDaLYI7VhusUrq kb3d+3zHl5wOWNJ6Aa2vdgUm2H9Mu2vLYiV6hJ7dzmkJcKuxH6rx9Y/Cem9KxM4zwcE4 9bBYveX2SfDaF5YIl62GXVoVLPnVbN4xE+hcyCQNq1x7/GJhB9n2msCYvhr86KxxqwvV 6dsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AJdk+y8NXF+RoH9Ae4ORRCDGI6GEwlgz+hw2CvaEpW0=; fh=ZJ836GL6jorYb+SbCfBeO8zhoMwg3TfE6doBJV4m2wI=; b=LYnCMnp40TMuTdAQqxEQMVizY38tma62LwAjLx0+pHfNHsS0Z9Ug8yoZjQfjjEt7rs HBp/hNJPebNWfliI3F7ncGZBB07ph4FGlYknvOQxMb2UDq8U7I85dF219RWmk6LFFgIN ZyhJNuZkfQt2O8GCGIOF9Invi/XzsvWfBbHVW95PR1Xbjys9ILg6uQ3hGrughlVbXfMS CKQ5Vdj2YInFqBeZ+3/ix6uDemFx8L+rnon9xrzxpNdz/8D9VQqc+OhAaYZ79BReMjRW ZFJLO62Ran24JfqJOMeFd6yGLI1sJUQmCc8Pr8Umo1ejgNBGQ7QaE9RK9oFdTnBLrJ8i MOyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E1zVf4tq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id nw16-20020a17090b255000b00262ca5c4c12si12161096pjb.178.2023.10.10.07.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E1zVf4tq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E8CB8028FFC; Tue, 10 Oct 2023 07:11:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232433AbjJJOLv (ORCPT + 99 others); Tue, 10 Oct 2023 10:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjJJOLu (ORCPT ); Tue, 10 Oct 2023 10:11:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4579FA7 for ; Tue, 10 Oct 2023 07:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696947106; x=1728483106; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2VBQXVArfIBgHPpUcs1zlQhsNpmKngH8nu0wk1tf7IE=; b=E1zVf4tqyawx63DGJ/6zR3z2nyHb8/WtxjTki3wB7IFd1UIvyzLu625H bB2+Zz5/a3BtBht2QfTsVSX74/v4BPxrnNH86enU7tfy9b1SF9E41m/3Y ciiU/RxIqbPLZwhkx7HKuhVFsp5sbEZG5Le5O75wMZyb1EzTBftkAedCS q4boTpv5nhH21GQnwCjLTf9WV/H8maMnFzg3vl2YuCxu5ENuTsxfPTacg 9tpyYZRa3ToqshT2T+B6FGjUhJUJopiaD/KlIWNin5oCbCcNPIfdbGmlf GaQnO0W7h50JI4KDjIFzqX3wzfIiDo4fDJxoElS2lTssod0umu2IutJJa Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="387241769" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="387241769" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 07:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="1084802382" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="1084802382" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 10 Oct 2023 07:11:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 49F5B35A; Tue, 10 Oct 2023 17:11:25 +0300 (EEST) From: Andy Shevchenko To: Dipen Patel , timestamp@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/1] hte: Use kasprintf() instead of fixed buffer formatting Date: Tue, 10 Oct 2023 17:11:23 +0300 Message-Id: <20231010141123.3909596-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:11:59 -0700 (PDT) X-Spam-Level: ** Improve readability and maintainability by replacing a hardcoded string allocation and formatting by the use of the kasprintf() helper. Signed-off-by: Andy Shevchenko --- drivers/hte/hte.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c index 1fd8d2d4528b..23a6eeb8c506 100644 --- a/drivers/hte/hte.c +++ b/drivers/hte/hte.c @@ -17,8 +17,6 @@ #include #include -#define HTE_TS_NAME_LEN 10 - /* Global list of the HTE devices */ static DEFINE_SPINLOCK(hte_lock); static LIST_HEAD(hte_devices); @@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb, atomic_inc(&gdev->ts_req); - ei->line_name = NULL; - if (!desc->attr.name) { - ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL); - if (ei->line_name) - scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u", - desc->attr.line_id); - } + if (desc->attr.name) + ei->line_name = NULL; + else + ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id); hte_ts_dbgfs_init(desc->attr.name == NULL ? ei->line_name : desc->attr.name, ei); -- 2.40.0.1.gaa8946217a0b