Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] libtraceevent: Fix bug in tep_print_event()
@ 2021-06-30 14:19 Yordan Karadzhov (VMware)
  2021-06-30 15:06 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Yordan Karadzhov (VMware) @ 2021-06-30 14:19 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

We must handle the case when the "tep_event" object is not found.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/event-parse.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index de28b3b..d3f1bba 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -6418,17 +6418,21 @@ void tep_print_event(struct tep_handle *tep, struct trace_seq *s,
 		     struct tep_record *record, const char *fmt, ...)
 {
 	struct print_event_type type;
-	char *format = strdup(fmt);
-	char *current = format;
-	char *str = format;
+	char *format, *current, *str;
 	int offset;
 	va_list args;
 	struct tep_event *event;
 
+	event = tep_find_event_by_record(tep, record);
+	if (!event) {
+		trace_seq_printf(s, "[UNKNOWN EVENT]");
+		return;
+	}
+
+	str = current = format = strdup(fmt);
 	if (!format)
 		return;
 
-	event = tep_find_event_by_record(tep, record);
 	va_start(args, fmt);
 	while (*current) {
 		current = strchr(str, '%');
-- 
2.27.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libtraceevent: Fix bug in tep_print_event()
  2021-06-30 14:19 [PATCH] libtraceevent: Fix bug in tep_print_event() Yordan Karadzhov (VMware)
@ 2021-06-30 15:06 ` Steven Rostedt
  2021-06-30 18:37   ` Yordan Karadzhov (VMware)
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2021-06-30 15:06 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: linux-trace-devel

On Wed, 30 Jun 2021 17:19:13 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> {
>  	struct print_event_type type;
> -	char *format = strdup(fmt);
> -	char *current = format;
> -	char *str = format;
> +	char *format, *current, *str;

Nit, but please keep the above each on a separate line.

	char *current;
	char *format;
	char *str;

I try to avoid having pointers on a single line, it's just easier to
manage when they are separate.

Thanks!

-- Steve

>  	int offset;
>  	va_list args;
>  	struct tep_event *event;
>  
> +	event = tep_find_event_by_record(tep, record);
> +	if (!event) {
> +		trace_seq_printf(s, "[UNKNOWN EVENT]");
> +		return;
> +	}
> +
> +	str = current = format = strdup(fmt);
>  	if (!format)
>  		return;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libtraceevent: Fix bug in tep_print_event()
  2021-06-30 15:06 ` Steven Rostedt
@ 2021-06-30 18:37   ` Yordan Karadzhov (VMware)
  2021-06-30 18:50     ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Yordan Karadzhov (VMware) @ 2021-06-30 18:37 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel



On 30.06.21 г. 18:06, Steven Rostedt wrote:
> On Wed, 30 Jun 2021 17:19:13 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> 
>> {
>>   	struct print_event_type type;
>> -	char *format = strdup(fmt);
>> -	char *current = format;
>> -	char *str = format;
>> +	char *format, *current, *str;
> 
> Nit, but please keep the above each on a separate line.
> 
> 	char *current;
> 	char *format;
> 	char *str;
> 
> I try to avoid having pointers on a single line, it's just easier to
> manage when they are separate.

I am sorry!
I somehow forgot that we already discussed this before.
Should I send v2?

Thanks,
Y.

> 
> Thanks!
> 
> -- Steve
> 
>>   	int offset;
>>   	va_list args;
>>   	struct tep_event *event;
>>   
>> +	event = tep_find_event_by_record(tep, record);
>> +	if (!event) {
>> +		trace_seq_printf(s, "[UNKNOWN EVENT]");
>> +		return;
>> +	}
>> +
>> +	str = current = format = strdup(fmt);
>>   	if (!format)
>>   		return;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libtraceevent: Fix bug in tep_print_event()
  2021-06-30 18:37   ` Yordan Karadzhov (VMware)
@ 2021-06-30 18:50     ` Steven Rostedt
  2021-06-30 19:38       ` Yordan Karadzhov (VMware)
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2021-06-30 18:50 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: linux-trace-devel

On Wed, 30 Jun 2021 21:37:48 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> On 30.06.21 г. 18:06, Steven Rostedt wrote:
> > On Wed, 30 Jun 2021 17:19:13 +0300
> > "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> >   
> >> {
> >>   	struct print_event_type type;
> >> -	char *format = strdup(fmt);
> >> -	char *current = format;
> >> -	char *str = format;
> >> +	char *format, *current, *str;  
> > 
> > Nit, but please keep the above each on a separate line.
> > 
> > 	char *current;
> > 	char *format;
> > 	char *str;
> > 
> > I try to avoid having pointers on a single line, it's just easier to
> > manage when they are separate.  
> 
> I am sorry!
> I somehow forgot that we already discussed this before.
> Should I send v2?
> 

Yeah, if it's not too much of a hassle.

Thanks,

-- Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libtraceevent: Fix bug in tep_print_event()
  2021-06-30 18:50     ` Steven Rostedt
@ 2021-06-30 19:38       ` Yordan Karadzhov (VMware)
  0 siblings, 0 replies; 5+ messages in thread
From: Yordan Karadzhov (VMware) @ 2021-06-30 19:38 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel



On 30.06.21 г. 21:50, Steven Rostedt wrote:
>> Should I send v2?
>>
> Yeah, if it's not too much of a hassle.

Done.

Thanks!
Y.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 14:19 [PATCH] libtraceevent: Fix bug in tep_print_event() Yordan Karadzhov (VMware)
2021-06-30 15:06 ` Steven Rostedt
2021-06-30 18:37   ` Yordan Karadzhov (VMware)
2021-06-30 18:50     ` Steven Rostedt
2021-06-30 19:38       ` Yordan Karadzhov (VMware)

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git