From mboxrd@z Thu Jan 1 00:00:00 1970 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 5041641B35D for ; Mon, 9 Mar 2026 19:58:20 +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=1773086301; cv=none; b=uQ0nGDY1I/m5YMufUJIisujHyZsAsq2xORvaMI1CH/+XQBAPs0QPvd7kVFJPTkc45batFRNJcU4rFemj2JmW0uyhLnawLTrQfQd0RDX6KCT+5UWTlgHIxjKiYPWxqGz29hjCRI60UB2bNNG8KZeRjmYGbRCz++A8AKJBPqBJg68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773086301; c=relaxed/simple; bh=D55xnz6iCNzlcAtNIUtflhHmWwWcCl5kxYEfp9qFz3Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=H1xqrJXDPcRcaxLsVH3YkKB+Wb3X1rd09rEWHZkjmxQUvTw50HE+/N9hQZI7ndQLfYRSfKwVDltkvNv7uiOYzY6tgcNMotAg5YQmxi7VpOq9CC7j/Pel4CgGdTy0bHVm7fjLM85iNv2fo8VDq02iQTTVkwVoV2FtiMy+Ll55hGE= 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=InLl8f5c; 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="InLl8f5c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773086299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6SVQf1w7udqyBNohV7iJ/lPQGOtr/0Atb6cfqiNh6HY=; b=InLl8f5cY//qwPR91qPzGNR4Vr7jsyCsnYXch9Gy760zpSyFl/XNq96msi1XZv77cKhHHe /TQeYSgicUXshSnQzfrn4zFdSu2dSIO/yqd3Hv+j1Y5dM0EnaN4B9COnB+olvxnEme+X+/ 47OPKRqIk92oQtIhwILz0QEIuoWVlE4= Received: from mx-prod-mc-03.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-400-0Tiuk0-mP-6CB8mc-3Jq8w-1; Mon, 09 Mar 2026 15:58:12 -0400 X-MC-Unique: 0Tiuk0-mP-6CB8mc-3Jq8w-1 X-Mimecast-MFC-AGG-ID: 0Tiuk0-mP-6CB8mc-3Jq8w_1773086289 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C8951955F39; Mon, 9 Mar 2026 19:58:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.81.10]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8144830002D2; Mon, 9 Mar 2026 19:58:04 +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 Bristot de Oliveira , Daniel Wagner , 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 v4 10/18] rtla: Add str_has_prefix() helper function Date: Mon, 9 Mar 2026 16:46:23 -0300 Message-ID: <20260309195040.1019085-11-wander@redhat.com> In-Reply-To: <20260309195040.1019085-1-wander@redhat.com> References: <20260309195040.1019085-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-MFC-PROC-ID: jWJtnD0bYTysC6eXtms0MEJzulE-FXBFoPKoGFRpO1s_1773086289 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Add a str_has_prefix() helper function that tests whether a string starts with a given prefix. This function provides a cleaner interface for prefix matching compared to using strncmp() with strlen() directly. The function returns a boolean value indicating whether the string starts with the specified prefix. This helper will be used in subsequent changes to simplify prefix matching code throughout rtla. Also add the missing string.h include which is needed for the strlen() and strncmp() functions used by str_has_prefix() and the existing strncmp_static() macro. Signed-off-by: Wander Lairson Costa --- tools/tracing/rtla/src/utils.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/tracing/rtla/src/utils.h b/tools/tracing/rtla/src/utils.h index 3bca53ee48db6..165d6d0a0c6ab 100644 --- a/tools/tracing/rtla/src/utils.h +++ b/tools/tracing/rtla/src/utils.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include @@ -24,6 +25,18 @@ /* Compare string with static string, length determined at compile time */ #define strncmp_static(s1, s2) strncmp(s1, s2, ARRAY_SIZE(s2)) +/** + * str_has_prefix - Test if a string has a given prefix + * @str: The string to test + * @prefix: The string to see if @str starts with + * + * Returns: true if @str starts with @prefix, false otherwise + */ +static inline bool str_has_prefix(const char *str, const char *prefix) +{ + return strncmp(str, prefix, strlen(prefix)) == 0; +} + #define container_of(ptr, type, member)({ \ const typeof(((type *)0)->member) *__mptr = (ptr); \ (type *)((char *)__mptr - offsetof(type, member)) ; }) -- 2.53.0