From nobody Sun Feb 8 21:33:54 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD07E2D9494 for ; Thu, 15 Jan 2026 17:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497911; cv=none; b=tmI6PL7QJclbDG5xWPpn8Iq27Qwv0J+Q3jxAbHiNx14/B1a9DGjSeDpDe4nwl1C9dhMjU4S9FzVWb908Cnh6q8EaWLrtUFiJXVa8CEjJvFBJk8qmJQocSr+I77mc1IT+sjWkb/0t0wzIF91LBWDmeCD1h5pavlrYAMV5be9cOE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497911; c=relaxed/simple; bh=b9UIcCzgHzv5dWFzcFJ8wptQQxfWpu7+N36izSipW0M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nj8xWhw5rO4LFSsKZcs2fgY2LTQ3KnQccgtOevgVam3Ycbbxoh6KAAvOHMCFw/4kyKiP6lviq32FSsd6EmlL0IuPRSDr2boYOaL8TKyZokYNV0JKqR93/mBtEipfczlD2RSDAU4b/x3DULaikPH6SFxoxESSdoFI33Ux54+m5I0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bV+xPRIe; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bV+xPRIe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768497908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=clIrUy6vZlEsDOhtFnJV3d0FNSzh4HR8QlMrRlaBWdo=; b=bV+xPRIe3SDHBZpri2Dqligj9txVIuZF3bk+/6ZheiTU3sr0mMD/2uzjE8BrrYIFBUUtRe 2VyYaMoUSoInXxFeG57/BQeFBAqgydQ5g9JZwjyj2O8glrjm2AEuUKyMLP7ZcRYLNzh4B2 RlOql2tVsaedqbeT28fk5N3FtJg19s0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-o3aZ0iaINpmInAaQNQmjCw-1; Thu, 15 Jan 2026 12:25:05 -0500 X-MC-Unique: o3aZ0iaINpmInAaQNQmjCw-1 X-Mimecast-MFC-AGG-ID: o3aZ0iaINpmInAaQNQmjCw_1768497904 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0F4FA195608E; Thu, 15 Jan 2026 17:25:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.87]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C63F18004D8; Thu, 15 Jan 2026 17:24:59 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Tomas Glozar , Wander Lairson Costa , Crystal Wood , Ivan Pravdin , Costa Shulyupin , John Kacur , Tiezhu Yang , Daniel Wagner , Daniel Bristot de Oliveira , linux-trace-kernel@vger.kernel.org (open list:Real-time Linux Analysis (RTLA) tools), linux-kernel@vger.kernel.org (open list:Real-time Linux Analysis (RTLA) tools), bpf@vger.kernel.org (open list:BPF [MISC]:Keyword:(?:\b|_)bpf(?:\b|_)) Subject: [PATCH v3 02/18] rtla: Use strdup() to simplify code Date: Thu, 15 Jan 2026 13:31:45 -0300 Message-ID: <20260115163650.118910-3-wander@redhat.com> In-Reply-To: <20260115163650.118910-1-wander@redhat.com> References: <20260115163650.118910-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The actions_add_trace_output() and actions_add_shell() functions were using calloc() followed by strcpy() to allocate and copy a string. This can be simplified by using strdup(), which allocates memory and copies the string in a single step. Replace the calloc() and strcpy() calls with strdup(), making the code more concise and readable. Signed-off-by: Wander Lairson Costa --- tools/tracing/rtla/src/actions.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/acti= ons.c index 22b8283a183f3..0ac42ffd734a3 100644 --- a/tools/tracing/rtla/src/actions.c +++ b/tools/tracing/rtla/src/actions.c @@ -69,8 +69,7 @@ actions_add_trace_output(struct actions *self, const char= *trace_output) =20 self->present[ACTION_TRACE_OUTPUT] =3D true; action->type =3D ACTION_TRACE_OUTPUT; - action->trace_output =3D calloc_fatal(strlen(trace_output) + 1, sizeof(ch= ar)); - strcpy(action->trace_output, trace_output); + action->trace_output =3D strdup_fatal(trace_output); } =20 /* @@ -97,8 +96,7 @@ actions_add_shell(struct actions *self, const char *comma= nd) =20 self->present[ACTION_SHELL] =3D true; action->type =3D ACTION_SHELL; - action->command =3D calloc_fatal(strlen(command) + 1, sizeof(char)); - strcpy(action->command, command); + action->command =3D strdup_fatal(command); } =20 /* --=20 2.52.0