* [PATCH v2] libtraceeval: Fix traceeval_insert() macro for NULL vals
@ 2023-09-29 9:13 Steven Rostedt
2023-10-02 20:45 ` Ross Zwisler
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2023-09-29 9:13 UTC (permalink / raw)
To: Linux Trace Devel; +Cc: Ross Zwisler, Stevie Alvarez
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If the vals is NULL (which is valid), the traceeval_insert() macro calls
traceeval_insert_size() with sizeof(vals)/sizeof(vals[0]) to get the
number of vals in the array. But this does not make sense with a NULL
value. Check for NULL and if vals is NULL then pass in zero.
Cc: Ross Zwisler <zwisler@google.com>
Cc: Stevie Alvarez <stevie.6strings@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
Changse since v1: https://lore.kernel.org/linux-trace-devel/20230928051511.074ab689@rorschach.local.home
- typecast "vals" to (void *) otherwise the compiler will warn that
comparing a structure to != NULL will always be true.
include/traceeval-hist.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
index 44d071f3231a..65a905034773 100644
--- a/include/traceeval-hist.h
+++ b/include/traceeval-hist.h
@@ -187,7 +187,7 @@ int traceeval_insert_size(struct traceeval *teval,
#define traceeval_insert(teval, keys, vals) \
traceeval_insert_size(teval, keys, TRACEEVAL_ARRAY_SIZE(keys), \
- vals, TRACEEVAL_ARRAY_SIZE(vals))
+ vals, (void *)vals == NULL ? 0 : TRACEEVAL_ARRAY_SIZE(vals))
int traceeval_remove_size(struct traceeval *teval,
const struct traceeval_data *keys, size_t nr_keys);
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] libtraceeval: Fix traceeval_insert() macro for NULL vals
2023-09-29 9:13 [PATCH v2] libtraceeval: Fix traceeval_insert() macro for NULL vals Steven Rostedt
@ 2023-10-02 20:45 ` Ross Zwisler
0 siblings, 0 replies; 2+ messages in thread
From: Ross Zwisler @ 2023-10-02 20:45 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Linux Trace Devel, Stevie Alvarez
On Fri, Sep 29, 2023 at 05:13:04AM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> If the vals is NULL (which is valid), the traceeval_insert() macro calls
> traceeval_insert_size() with sizeof(vals)/sizeof(vals[0]) to get the
> number of vals in the array. But this does not make sense with a NULL
> value. Check for NULL and if vals is NULL then pass in zero.
>
> Cc: Ross Zwisler <zwisler@google.com>
> Cc: Stevie Alvarez <stevie.6strings@gmail.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Ross Zwisler <zwisler@google.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-02 20:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-29 9:13 [PATCH v2] libtraceeval: Fix traceeval_insert() macro for NULL vals Steven Rostedt
2023-10-02 20:45 ` Ross Zwisler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).