libtracefs: Fix spelling in test name
PATCH 1/3 libtracefs: Fix spelling in test name
Synthetic rather than syntetic.
--- utest/tracefs-utest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
utest/tracefs-utest.c +3 -3
@@ -436,7 +436,7 @@ static void test_synth_compare(struct test_synth *synth, struct tracefs_dyneventCU_TEST (devents[i] ==NULL ); } -static void test_instance_syntetic (struct tracefs_instance *instance) +static void test_instance_synthetic (struct tracefs_instance *instance) {struct test_synth sevents[] = { {"synth_1" ,"sched" ,"sched_waking" ,"sched" ,"sched_switch" ,"pid" ,"next_pid" ,"pid_match" },
@@ -496,7 +496,7 @@ static void test_instance_syntetic(struct tracefs_instance *instance)static void test_synthetic (void ) { -test_instance_syntetic (test_instance); +test_instance_synthetic (test_instance); }static void test_trace_file (void )
@@ -1706,6 +1706,6 @@ void test_tracefs_lib(void)CU_add_test (suite,"ftrace marker" , test_ftrace_marker);CU_add_test (suite,"kprobes" , test_kprobes); -CU_add_test (suite,"syntetic events" , test_synthetic); +CU_add_test (suite,"synthetic events" , test_synthetic);CU_add_test (suite,"eprobes" , test_eprobes); }
Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
PATCH 2/3 libtracefs: Avoid null access
The for loop handles devents == NULL, but the test afterwards needs to also.
--- utest/tracefs-utest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utest/tracefs-utest.c +1 -1
@@ -433,7 +433,7 @@ static void test_synth_compare(struct test_synth *synth, struct tracefs_dyneventfree (event);free (format); } -CU_TEST (devents[i] ==NULL ); +CU_TEST (devents ==NULL || devents[i] ==NULL ); }static void test_instance_synthetic (struct tracefs_instance *instance)
Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
PATCH 3/3 libtracefs: Move initialization below a null test.
In reply to Ian RogersComputing the address from a NULL pointer results in undefined behavior which things like undefined behavior sanitizer promote into real failures.
--- src/tracefs-dynevents.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/tracefs-dynevents.c +7 -2
@@ -724,13 +724,18 @@ tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format) { char **lv[] = { system, event, prefix, addr, format }; -char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix, - &dynevent->address, &dynevent->format }; +char **rv[] = {NULL ,NULL ,NULL ,NULL ,NULL };int i;if (!dynevent)return TRACEFS_DYNEVENT_UNKNOWN ; + rv[0 ] = &dynevent->system; + rv[1 ] = &dynevent->event; + rv[2 ] = &dynevent->prefix; + rv[3 ] = &dynevent->address; + rv[4 ] = &dynevent->format; +for (i =0 ; i <ARRAY_SIZE (lv); i++) {if (lv[i]) {if (*rv[i]) {
Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
Re: [PATCH 3/3] libtracefs: Move initialization below a null test.
Quoted 14 lines · On Thu, 24 Feb 2022 15:48:23 -0800 Ian Rogers <[email protected]> wrote:
Computing the address from a NULL pointer results in undefined behavior which things like undefined behavior sanitizer promote into real failures.
Signed-off-by Ian Rogers <[email protected]>--- src/tracefs-dynevents.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)src/tracefs-dynevents.c +0
-0
src/tracefs-dynevents.c tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, · line 728
Quoted 7 lines
src/tracefs-dynevents.c +1
-2@@ -724,13 +724,18 @@ tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format) { char **lv[] = { system, event, prefix, addr, format }; -char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix, - &dynevent->address, &dynevent->format }; +char **rv[] = {NULL ,NULL ,NULL ,NULL ,NULL };int i;
I don't really like the NULL initialization done like this.
What about just adding a helper function. That is.
src/tracefs-dynevents.c +27 -18
@@ -704,24 +704,9 @@ __hidden int dynevent_get_count(unsigned int types, const char *system)return all; } -/** -* tracefs_dynevent_info - return details of a dynamic event -* @dynevent: A dynamic event context, describing given dynamic event. -* @group: return, group in which the dynamic event is configured -* @event: return, name of the dynamic event -* @prefix: return, prefix string of the dynamic event -* @addr: return, the function and offset (or address) of the dynamic event -* @format: return, the format string of the dynamic event -* -* Returns the type of the dynamic event, or TRACEFS_DYNEVENT_UNKNOWN in case of an error. -* Any of the @group, @event, @prefix, @addr and @format parameters are optional. -* If a valid pointer is passed, in case of success - a string is allocated and returned. -* These strings must be freed with free(). -*/ - -enum tracefs_dynevent_type -tracefs_dynevent_info (struct tracefs_dynevent *dynevent,char **system, -char **event,char **prefix,char **addr,char **format) +static enum tracefs_dynevent_type +dynevent_info (struct tracefs_dynevent *dynevent,char **system, +char **event,char **prefix,char **addr,char **format) {char **lv[] = { system, event, prefix, addr, format };char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix,
@@ -754,6 +739,30 @@ error:return TRACEFS_DYNEVENT_UNKNOWN ; } +/** +* tracefs_dynevent_info - return details of a dynamic event +* @dynevent: A dynamic event context, describing given dynamic event. +* @group: return, group in which the dynamic event is configured +* @event: return, name of the dynamic event +* @prefix: return, prefix string of the dynamic event +* @addr: return, the function and offset (or address) of the dynamic event +* @format: return, the format string of the dynamic event +* +* Returns the type of the dynamic event, or TRACEFS_DYNEVENT_UNKNOWN in case of an error. +* Any of the @group, @event, @prefix, @addr and @format parameters are optional. +* If a valid pointer is passed, in case of success - a string is allocated and returned. +* These strings must be freed with free(). +*/ +enum tracefs_dynevent_type +tracefs_dynevent_info (struct tracefs_dynevent *dynevent,char **system, +char **event,char **prefix,char **addr,char **format) +{ +if (!dynevent) +return TRACEFS_DYNEVENT_UNKNOWN ; + +return dynevent_info (dynevent, system, event, prefix, addr, format); +} +/** * tracefs_dynevent_get_event - return tep event representing the given dynamic event * @tep: a handle to the trace event parser context that holds the events
-- Steve
Re: [PATCH 3/3] libtracefs: Move initialization below a null test.
Quoted 84 lines · Steven Rostedt
Quoted 14 lines · On Thu, 24 Feb 2022 15:48:23 -0800 Ian Rogers <[email protected]> wrote:
Computing the address from a NULL pointer results in undefined behavior which things like undefined behavior sanitizer promote into real failures.
Signed-off-by Ian Rogers <[email protected]>--- src/tracefs-dynevents.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)src/tracefs-dynevents.c +0
-0src/tracefs-dynevents.c tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, · line 728
Quoted 7 lines
src/tracefs-dynevents.c +1
-2@@ -724,13 +724,18 @@ tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format) { char **lv[] = { system, event, prefix, addr, format }; -char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix, - &dynevent->address, &dynevent->format }; +char **rv[] = {NULL ,NULL ,NULL ,NULL ,NULL };int i;I don't really like the NULL initialization done like this.
What about just adding a helper function. That is.
src/tracefs-dynevents.c +20
-18@@ -704,24 +704,9 @@ __hidden int dynevent_get_count(unsigned int types, const char *system)return all; } -/** -* tracefs_dynevent_info - return details of a dynamic event -* @dynevent: A dynamic event context, describing given dynamic event. -* @group: return, group in which the dynamic event is configured -* @event: return, name of the dynamic event -* @prefix: return, prefix string of the dynamic event -* @addr: return, the function and offset (or address) of the dynamic event -* @format: return, the format string of the dynamic event -* -* Returns the type of the dynamic event, or TRACEFS_DYNEVENT_UNKNOWN in case of an error. -* Any of the @group, @event, @prefix, @addr and @format parameters are optional. -* If a valid pointer is passed, in case of success - a string is allocated and returned. -* These strings must be freed with free(). -*/ - -enum tracefs_dynevent_type -tracefs_dynevent_info (struct tracefs_dynevent *dynevent,char **system, -char **event,char **prefix,char **addr,char **format) +static enum tracefs_dynevent_type +dynevent_info (struct tracefs_dynevent *dynevent,char **system, +char **event,char **prefix,char **addr,char **format) {char **lv[] = { system, event, prefix, addr, format };char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix,@@ -754,6 +739,30 @@ error:return TRACEFS_DYNEVENT_UNKNOWN ; } +/** +* tracefs_dynevent_info - return details of a dynamic event +* @dynevent: A dynamic event context, describing given dynamic event. +* @group: return, group in which the dynamic event is configured +* @event: return, name of the dynamic event +* @prefix: return, prefix string of the dynamic event +* @addr: return, the function and offset (or address) of the dynamic event +* @format: return, the format string of the dynamic event +* +* Returns the type of the dynamic event, or TRACEFS_DYNEVENT_UNKNOWN in case of an error. +* Any of the @group, @event, @prefix, @addr and @format parameters are optional. +* If a valid pointer is passed, in case of success - a string is allocated and returned. +* These strings must be freed with free(). +*/ +enum tracefs_dynevent_type +tracefs_dynevent_info (struct tracefs_dynevent *dynevent,char **system, +char **event,char **prefix,char **addr,char **format)
src/tracefs-dynevents.c error: · line 768
Quoted 10 lines
src/tracefs-dynevents.c +7
-0+{ +if (!dynevent) +return TRACEFS_DYNEVENT_UNKNOWN ; + +return dynevent_info (dynevent, system, event, prefix, addr, format); +} +/** * tracefs_dynevent_get_event - return tep event representing the given dynamic event * @tep: a handle to the trace event parser context that holds the events
LGTM. Thanks,
Ian
Quoted 1 line
-- Steve
Re: [PATCH 3/3] libtracefs: Move initialization below a null test.
Quoted 6 lines · On Thu, 24 Feb 2022 16:09:29 -0800 Ian Rogers <[email protected]> wrote:
Quoted 4 lines
/**
*tracefs_dynevent_get_event- return tep event representing the given dynamic event
* @tep: a handle to the trace event parser context that holds the eventsLGTM. Thanks,
Did you want to resend, or do you want me to just do this myself? I'm good either way.
-- Steve
Re: [PATCH 3/3] libtracefs: Move initialization below a null test.
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Thu, 24 Feb 2022 16:09:29 -0800 Ian Rogers <[email protected]> wrote:
Quoted 4 lines
/**
*tracefs_dynevent_get_event- return tep event representing the given dynamic event
* @tep: a handle to the trace event parser context that holds the events
Quoted 4 lines
Quoted 1 line
LGTM. Thanks,
Did you want to resend, or do you want me to just do this myself? I'm good either way.
Happy to let you do it. Thanks,
Ian
Quoted 1 line
-- Steve