Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1144935lql; Tue, 12 Mar 2024 08:28:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnDCA0C+rNRNrJAmoMMTfCSu9AIOBSNcvI/9pZOhZP88eRKUqYRYmq7/BUSkMeOjtPFojDASjzetRBbE2JqF5yRHCFuTavBMLpK1Ykjw== X-Google-Smtp-Source: AGHT+IHk2LH3BunidWOUXca3Ym75T1A73v6yAKvqJL7gVMbw5tvKsj3wVA0sWXzcrB5kMPubVaN5 X-Received: by 2002:a05:6358:5790:b0:17b:f37f:69da with SMTP id m16-20020a056358579000b0017bf37f69damr781618rwf.8.1710257310332; Tue, 12 Mar 2024 08:28:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710257310; cv=pass; d=google.com; s=arc-20160816; b=zm/ODj847WBX2sotZxEBFxQ3ZM8MYkCtd2sH50dc4YMOOiOEbdPir/oqHZo3IhbXuo EZ3O25WVayWiV+Ms7bH9Uw/PC/1SLW1rAccNh9LWGP82BqHMpzC5R/qT532byByPEHHi XDFthx4ZDov3W3R6GeybJKsKoZTQ/E4GPrU64h9+AXpfU22p2NqvcAiTrzThbdsgjDNf tTtbdUpjIn/1QuXaong/U0ONFlSxZ0uS0PIMWtHqdxuiWoxU8K3JWSjoB+O/4BNzpstV tOyTCYrqhgpTlKg/Z7TvnZ/UYXc1/sTWRGllIRRETRg/3NZ5ENa7KTQxfrRXbpcVQU6z 5TSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=S4W2sLfwqgx6UR/BvkzznXU9Ut3fC/Taddh0l4v7O7I=; fh=0cNcRZe6V2JeKs9c88PyRa8nPHxaWwxZq2kABTwHpPs=; b=iB+FqyZfmzdYGfC1DCG02EgT79eCieOFe3m3tPwg8LAWfgl3ogLUoFx0tCA5nVZV44 zu+QJ6bv2wGojALPtXp4pyuHuPTe6q2Pvh4juXIgoiPgIJTWSIM5uuOyN/LYtrLasNVl BN28Nc5aoWZgjekRYPFQ/2Kif8mwmXnd4U3cEATg4+6M5+JHWkh099+oJYCoh6CMKa7H D46x6h/HiE6jmEcRRA5rbuc3yr9r/OsGBQITT24DFCRUfyDrbfRkixzhSgKvkVEKLDOI 9T/ZxPh50eaNI4yIGjw6hZKzhftmhJHUdBeG/CBift1zabfN8IBYk5Tw+aRwWT9/dJ6n SK7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-100435-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100435-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 25-20020a631859000000b005dc905460d6si7200459pgy.315.2024.03.12.08.28.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 08:28:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100435-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-100435-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100435-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 282662866D7 for ; Tue, 12 Mar 2024 15:28:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 985137C6C8; Tue, 12 Mar 2024 15:27:58 +0000 (UTC) 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 206DE58AD4; Tue, 12 Mar 2024 15:27:57 +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=1710257278; cv=none; b=TqqOaqcWGCPa/7h58wQvqxUB1A0VwgXHK6GeUXy84CgGEVF918/FO5yRKszW+0K90l0HL7rhGGygvF+Awq+5G4Jk/pUo8IDToe7AwBLX9V2QswPurUmIvuV8xU5o9s9MvsHtrEhvOx7AqFWvQeLrCd5yrO7agx6PSQT1CktF5vU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710257278; c=relaxed/simple; bh=6b7L4Sbs/Q00lM4mIgsLsO8GHS3s4iVoc322HloRkfo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=s2b8c553faPY86HDXXLxMEVq465sucPF3Gzj3clVjBuavLcQmY5rxEcYhHdo7Ev/q4QP8/F4KLBWMPjVyDHpyB1hIUUR8cobrjQ5UwYhSQodJYergWU+bbL0ATOAC/A6z0m15m+IYhtbRaQWm5bvP41mCnZpC6xxYNrrCXrM58g= 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 C73D6C433C7; Tue, 12 Mar 2024 15:27:56 +0000 (UTC) Date: Tue, 12 Mar 2024 11:30:02 -0400 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers , kernel test robot , Nathan Chancellor Subject: [PATCH] tracing: Use strcmp() in __assign_str() WARN_ON() check Message-ID: <20240312113002.00031668@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare] 670 | __assign_str(progname, "unknown"); That's because the __assign_str() macro has: WARN_ON_ONCE((src) != __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. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402292111.KIdExylU-lkp@intel.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/stages/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__ = __get_str(dst); \ int __len__ = __get_dynamic_array_len(dst) - 1; \ - WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_); \ + WARN_ON_ONCE(__builtin_constant_p(src) ? \ + strcmp((src), __data_offsets.dst##_ptr_) : \ + (src) != __data_offsets.dst##_ptr_); \ memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ EVENT_NULL_STR, __len__); \ __str__[__len__] = '\0'; \ -- 2.43.0