All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Alison Schofield <alison.schofield@intel.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2] cxl/trace: Properly initialize cxl_poison region name
Date: Thu, 14 Mar 2024 17:17:37 -0400	[thread overview]
Message-ID: <20240314171737.2025ef60@gandalf.local.home> (raw)
In-Reply-To: <ZfNmfCmgCs4Nc+EH@aschofie-mobl2>

On Thu, 14 Mar 2024 14:05:00 -0700
Alison Schofield <alison.schofield@intel.com> wrote:

> > I'm still curious to why NULL didn't work. I guess it may never have as I
> > noticed there's nothing else doing that. There are cases that a variable
> > returns NULL and the __string() handles it. But I guess the compiler gets
> > confused if the NULL is a possible return to the condition in __string().  
> 
> Here's the full warning spew:
> 
> In file included from ./include/trace/define_trace.h:102,
>                  from drivers/cxl/core/trace.h:713,
>                  from drivers/cxl/core/trace.c:8:
> drivers/cxl/core/./trace.h: In function ‘trace_event_get_offsets_cxl_poison’:
> ./include/trace/stages/stage5_get_offsets.h:50:21: warning: argument 1 null where non-null expected [-Wnonnull]
>    50 |                     strlen((src) ? (const char *)(src) : "(null)") + 1)
>       |                     ^~~~~~
> ./include/trace/trace_events.h:263:9: n

The full warning didn't add any new information. The above was all I
needed. But I'm curious if you applied this patch if the warning will go
away. (Note I didn't test nor compile this).

-- Steve

diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h
index e30a13be46ba..dfae18d8f4df 100644
--- a/include/trace/stages/stage5_get_offsets.h
+++ b/include/trace/stages/stage5_get_offsets.h
@@ -9,6 +9,13 @@
 #undef __entry
 #define __entry entry
 
+static inline const char *__string_src(const char *str)
+{
+	if (!str)
+		return "(null)";
+	return str;
+}
+
 /*
  * Fields should never declare an array: i.e. __field(int, arr[5])
  * If they do, it will cause issues in parsing and possibly corrupt the
@@ -47,7 +54,7 @@
 
 #undef __string
 #define __string(item, src) __dynamic_array(char, item,			\
-		    strlen((src) ? (const char *)(src) : "(null)") + 1)
+		    strlen(__string_src(src)) + 1)
 
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1)

  reply	other threads:[~2024-03-14 21:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 20:12 [PATCH v2] cxl/trace: Properly initialize cxl_poison region name alison.schofield
2024-03-14 20:41 ` Steven Rostedt
2024-03-14 21:05   ` Alison Schofield
2024-03-14 21:17     ` Steven Rostedt [this message]
2024-03-14 22:36       ` Alison Schofield
2024-03-14 22:50         ` Steven Rostedt
2024-03-15 10:47         ` Steven Rostedt
2024-03-15 16:18           ` Dan Williams
2024-03-15 16:30             ` Steven Rostedt
2024-03-14 20:51 ` Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240314171737.2025ef60@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.