From patchwork Sat Oct 21 14:42:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 156453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp327558vqx; Sat, 21 Oct 2023 07:42:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkHBQBM55JDi9uizZgOyCB2BVbB+HcvNZaE/w18xF5CWSAwaPnpsMU5kc60t2kLSTNim0b X-Received: by 2002:a17:90a:f2d2:b0:27d:3f43:d9c0 with SMTP id gt18-20020a17090af2d200b0027d3f43d9c0mr3814943pjb.24.1697899378543; Sat, 21 Oct 2023 07:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697899378; cv=none; d=google.com; s=arc-20160816; b=SyOUIsoJlaaVXguBSkJ53krV1zR5AiUBlAPDmNtytnt0cD1XB8z25TDFWIRl1QIToO +Vrn670P5Fyqh6R2zQ/rcyjcFcKHKTAj4Uc/TGVwG3Ste4fceYIgiLHl+jHQbUD3HvaD z5i5jyZZYAK6iQEpS8GS3ALWaBWGkDMnLFjOHOwlO+zXtchC+btXTvDPgHCO4YOx2PTl R/33cED6HQQJh0UmQV0b+DpDTT5tJ/wjqkxOfUZ0RO29RD6lITlK0hbuxLkcRbB4KkpZ t4NGHW4x1hBLbA5CetardaAQnbe1t94HFCaDyQ8QQq5fovFpvNMKWT9WUzrJ5JGr5OIH 0hLw== 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=3H3iB1o0U56oUpj2NNlHh/Qb8eqSMHeR5kXDOCLd6wk=; fh=UoeOvRRbD2q2Lu88gUJfF5KPD1RUHvm4w7hlK4rXRkY=; b=mKoVX+Flvg6ffv3oZqDFkQ80Qjlz2ohmmwfywkiz38W1gFN0hKCTuUwkBPSL89B2Ok SAArcncKb6uTZonpbTtfUjd3YIXnkHiyO+XqhXCdF6XBd8iqH6D0op53wHXNmoc6JmIH DPpX92ur65pSrq1pCk/WU9mvMeafTI9mmD9SkXsy6arZq3tzIFQgeKyEgACtMDtCfm93 UJVu/+x217WooRKFFugPQ9YR2Ze5tXhLm69lydui+tt4mSVGD05i+YG14Rf6Hvx61hHv DUs2a7lRVMGTi/dJeZIU+Cu729PGUrZkjnAROHIuGFGo1zV2NSupJ2XEWJfCwMxWwpSU gpBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TSxMsNg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 17-20020a17090a035100b00277453e82fesi3592285pjf.87.2023.10.21.07.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 07:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TSxMsNg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2C954809F391; Sat, 21 Oct 2023 07:42:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231364AbjJUOmu (ORCPT + 26 others); Sat, 21 Oct 2023 10:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231177AbjJUOmt (ORCPT ); Sat, 21 Oct 2023 10:42:49 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A7CD52 for ; Sat, 21 Oct 2023 07:42:46 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id uDBbqgbfUVj79uDBbqzxvu; Sat, 21 Oct 2023 16:42:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1697899364; bh=3H3iB1o0U56oUpj2NNlHh/Qb8eqSMHeR5kXDOCLd6wk=; h=From:To:Cc:Subject:Date; b=TSxMsNg7DMA+AP8vkTnZTGrRP4BHceZpcG3u/RSZgmZEFDfU957Vbw5xZpAOfj8VT zI4ns9LJxrWO0UvRes9B2Z+KuA0uuKicVJvqMJxJxFWaLYfeC60d4kq8t2otC3yxM9 Nmz9ohk18Nf+Ikrv8QXZ9hVBkrOgEA72h4U9uMyV8YVj/LPP4AVqz3NwuzSWUqQap/ MMJ+Q1OOhVFMk9XmfwCsir9tindADxYRFflTmt//s4AuMR78MB5+J698bCY+zBBvz5 wtHnTJohx93zkdH9q/N9Nzbfgru9AOGjD55vepHuSgFBhROWUHNBn/YLaVYEPRYZJh ea3uoSSPQjhzw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 21 Oct 2023 16:42:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Steven Rostedt , Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-trace-kernel@vger.kernel.org Subject: [PATCH] tracing/histograms: Simplify last_cmd_set() Date: Sat, 21 Oct 2023 16:42:41 +0200 Message-Id: <30b6fb04dadc10a03cc1ad08f5d8a93ef623a167.1697899346.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sat, 21 Oct 2023 07:42:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780376538869428667 X-GMAIL-MSGID: 1780376538869428667 Turn a kzalloc()+strcpy()+strncat() into an equivalent and less verbose kasprintf(). Signed-off-by: Christophe JAILLET Reviewed-by: Mukesh ojha --- kernel/trace/trace_events_hist.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index d06938ae0717..1abc07fba1b9 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -774,23 +774,16 @@ static void last_cmd_set(struct trace_event_file *file, char *str) { const char *system = NULL, *name = NULL; struct trace_event_call *call; - int len; if (!str) return; - /* sizeof() contains the nul byte */ - len = sizeof(HIST_PREFIX) + strlen(str); kfree(last_cmd); - last_cmd = kzalloc(len, GFP_KERNEL); + + last_cmd = kasprintf(GFP_KERNEL, HIST_PREFIX "%s", str); if (!last_cmd) return; - strcpy(last_cmd, HIST_PREFIX); - /* Again, sizeof() contains the nul byte */ - len -= sizeof(HIST_PREFIX); - strncat(last_cmd, str, len); - if (file) { call = file->event_call; system = call->class->system;