From nobody Sun Feb 8 20:32:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 16DE870CDE for ; Thu, 14 Mar 2024 14:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710426085; cv=none; b=FGViZUwskk3P7QETA13hs+ksjLaAsWQ75Px44DscqQ0nFsqTf1+NKufbSdm/fnqNEH3hXM4m6IstsMODABpqhhR0CZNuygxFr0NnuAhbytBL8DKtGdz7MYw+aXVehK7vxD1fkiW0JugAdVHqEJaEjrj79XxmR8XvJfm1ISeZnuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710426085; c=relaxed/simple; bh=ITYjfWzRNvPA40h3ntsvuJ1TUwwxrgRbD4mfqfcOLvo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=dtKM4Ek0tP9N2gzeXQ83upfLJ3Q8ZrKr2mFq+12Q9zCoAX4RZ3sdHHviIikfGMIXkHlyDBcozWNn5WlcYpkDBH/TM3RrWB4Juzv6q2xYSdftjIj8Udf3aiL55KBQ+RZlry59MSGPU7jlo96Qjh9vt8AQ1lnhZOcGhOtn33lGp7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85401C43394; Thu, 14 Mar 2024 14:21:24 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rklzb-00000002dgP-41ND; Thu, 14 Mar 2024 10:23:35 -0400 Message-ID: <20240314142335.820517632@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 14 Mar 2024 10:23:09 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Nathan Chancellor , kernel test robot Subject: [for-next][PATCH 8/8] tracing: Use strcmp() in __assign_str() WARN_ON() check References: <20240314142301.170713485@goodmis.org> 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 Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" The WARN_ON() check in __assign_str() to catch where the source variable to the macro doesn't match the source variable to __string() gives an error in clang: >> include/trace/events/sunrpc.h:703:4: warning: result of comparison again= st a string literal is unspecified (use an explicit string comparison funct= ion instead) [-Wstring-compare] 670 | __assign_str(progname, "unknown"); That's because the __assign_str() macro has: WARN_ON_ONCE((src) !=3D __data_offsets.dst##_ptr_); Where "src" is a string literal. Clang warns when comparing a string literal directly as it is undefined to what the value of the literal is. Since this is still to make sure the same string that goes to __string() is the same as __assign_str(), for string literals do a test for that and then use strcmp() in those cases Note that this depends on commit 51270d573a8d ("tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string") being applied, as this was what found that bug. Link: https://lore.kernel.org/linux-trace-kernel/20240312113002.00031668@ga= ndalf.local.home Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Nathan Chancellor Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402292111.KIdExylU-lkp@int= el.com/ Fixes: 433e1d88a3be ("tracing: Add warning if string in __assign_str() does= not match __string()") Signed-off-by: Steven Rostedt (Google) --- include/trace/stages/stage6_event_callback.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/s= tages/stage6_event_callback.h index a0c15f67eabe..83da83a0c14f 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -35,7 +35,9 @@ do { \ char *__str__ =3D __get_str(dst); \ int __len__ =3D __get_dynamic_array_len(dst) - 1; \ - WARN_ON_ONCE((src) !=3D __data_offsets.dst##_ptr_); \ + WARN_ON_ONCE(__builtin_constant_p(src) ? \ + strcmp((src), __data_offsets.dst##_ptr_) : \ + (src) !=3D __data_offsets.dst##_ptr_); \ memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ EVENT_NULL_STR, __len__); \ __str__[__len__] =3D '\0'; \ --=20 2.43.0