kernel-shark-qt: Deal with the "no tasks" case in kshark_get_task_pids()
PATCH 1/2 kernel-shark-qt: Deal with the "no tasks" case in kshark_get_task_pids()
kshark_get_task_pids() should not return a "memory allocation" error in the case when it is called before having trace data loaded.
--- kernel-shark-qt/src/libkshark.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel-shark-qt/src/libkshark.c +6 -0
@@ -303,6 +303,12 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } } +if (!pid_count) { +free (*pids); + *pids =NULL ; +return pid_count; + } + temp_pids =realloc (*pids, pid_count *sizeof (int ));if (!temp_pids) goto fail;
Signature · 1 line
2.17.1
PATCH 2/2 kernel-shark-qt: Fix the default value of the Event Visible flag
This patch fixes a simpel bug in the way the "Event Visible" flag of the kshark_entries is set when the data is loadded.
--- kernel-shark-qt/src/libkshark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark-qt/src/libkshark.c +1 -1
@@ -600,7 +600,7 @@ static size_t get_records(struct kshark_context *kshark_ctx,kshark_set_entry_values (kshark_ctx, rec, entry); pid = entry->pid;/* Apply event filtering. */ - ret =FILTER_NONE ; + ret =FILTER_MATCH ;if (adv_filter->filters) ret =pevent_filter_match (adv_filter, rec);
Signature · 1 line
2.17.1
Steven Rostedt
AppliedRe: [PATCH 2/2] kernel-shark-qt: Fix the default value of the Event Visible flag
Quoted 5 lines · On Wed, 11 Jul 2018 16:37:09 +0300 "Yordan Karadzhov (VMware)"…
This patch fixes a simpel bug in the way the "Event Visible" flag of the
kshark_entriesis set when the data is loadded.Signed-off-by Yordan Karadzhov (VMware) <[email protected]>---
Applied. Thanks Yordan!
-- Steve
Quoted 15 lines · On Wed, 11 Jul 2018 16:37:08 +0300 "Yordan Karadzhov (VMware)"…
kshark_get_task_pids()should not return a "memory allocation" error in the case when it is called before having trace data loaded.Signed-off-by Yordan Karadzhov (VMware) <[email protected]>--- kernel-shark-qt/src/libkshark.c | 6 ++++++ 1 file changed, 6 insertions(+)kernel-shark-qt/src/libkshark.c +0
-0@@ -303,6 +303,12 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } }
kernel-shark-qt/src/libkshark.c ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) · line 314
Quoted 10 lines
kernel-shark-qt/src/libkshark.c +6
-0+if (!pid_count) { +free (*pids); + *pids =NULL ; +return pid_count; + } + temp_pids =realloc (*pids, pid_count *sizeof (int ));if (!temp_pids) goto fail;
What about doing it this way:
kernel-shark-qt/src/libkshark.c +10 -5
@@ -303,12 +303,17 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } } - temp_pids =realloc (*pids, pid_count *sizeof (int )); -if (!temp_pids) - goto fail; +if (pid_count) { + temp_pids =realloc (*pids, pid_count *sizeof (int )); +if (!temp_pids) + goto fail; -/* Paranoid: In the unlikely case of shrinking *pids, realloc moves it */ - *pids = temp_pids; +/* Paranoid: In the unlikely case of shrinking *pids, realloc moves it */ + *pids = temp_pids; + }else { +free (*pids); + *pids =NULL ; + }return pid_count;
?
-- Steve
Quoted 48 lines · Steven Rostedt
Quoted 15 lines · On Wed, 11 Jul 2018 16:37:08 +0300 "Yordan Karadzhov (VMware)"…
kshark_get_task_pids()should not return a "memory allocation" error in the case when it is called before having trace data loaded.Signed-off-by Yordan Karadzhov (VMware) <[email protected]>--- kernel-shark-qt/src/libkshark.c | 6 ++++++ 1 file changed, 6 insertions(+)kernel-shark-qt/src/libkshark.c +0
-0@@ -303,6 +303,12 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } }kernel-shark-qt/src/libkshark.c ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) · line 314
Quoted 10 lines
kernel-shark-qt/src/libkshark.c +6
-0+if (!pid_count) { +free (*pids); + *pids =NULL ; +return pid_count; + } + temp_pids =realloc (*pids, pid_count *sizeof (int ));if (!temp_pids) goto fail;What about doing it this way:
kernel-shark-qt/src/libkshark.c +4
-4@@ -303,12 +303,17 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } } - temp_pids =realloc (*pids, pid_count *sizeof (int )); -if (!temp_pids) - goto fail; +if (pid_count) { + temp_pids =realloc (*pids, pid_count *sizeof (int )); +if (!temp_pids) + goto fail; -/* Paranoid: In the unlikely case of shrinking *pids, realloc moves it */
kernel-shark-qt/src/libkshark.c ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) · line 319
Quoted 10 lines
kernel-shark-qt/src/libkshark.c +6
-1- *pids = temp_pids; +/* Paranoid: In the unlikely case of shrinking *pids, realloc moves it */ + *pids = temp_pids; + }else { +free (*pids); + *pids =NULL ; + }return pid_count;
Yes, this way is better.
Thanks!
Yordan
Quoted 5 lines
?
-- Steve
Hi Steven,
Should I send this patch again?
Thanks!
Yordan
Quoted 40 lines · Yordan Karadzhov (VMware)
Quoted 21 lines
What about doing it this way:
kernel-shark-qt/src/libkshark.c +4
-4@@ -303,12 +303,17 @@ ssize_t kshark_get_task_pids(struct kshark_context *kshark_ctx, int **pids) } } - temp_pids = realloc(*pids, pid_count * sizeof(int)); - if (!temp_pids) - goto fail; + if (pid_count) { + temp_pids = realloc(*pids, pid_count * sizeof(int)); + if (!temp_pids) + goto fail; - /* Paranoid: In the unlikely case of shrinking *pids, reallocmoves it */
- *pids =temp_pids;Quoted 8 lines
+ /* Paranoid: In the unlikely case of shrinking *pids, realloc moves it */
+ *pids =temp_pids;
+ } else {
+free(*pids);
+ *pids = NULL;
+ }
returnpid_count;Yes, this way is better.
Thanks!
YordanQuoted 4 lines
?
-- Steve
Quoted 2 lines · On Fri, 3 Aug 2018 16:06:24 +0300 "Yordan Karadzhov (VMware)"…
Hi Steven,
Should I send this patch again?
Yes, with the updates.
Thanks!
-- Steve
Quoted 8 lines · On Fri, 3 Aug 2018 13:46:22 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines · On Fri, 3 Aug 2018 16:06:24 +0300 "Yordan Karadzhov (VMware)"…
Hi Steven,
Should I send this patch again?Yes, with the updates.
I take this back. I'll do the updates and apply your other patches on top.
Thanks!
-- Steve
Quoted 6 lines · On Fri, 3 Aug 2018 14:18:27 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Fri, 3 Aug 2018 13:46:22 -0400 Steven Rostedt <[email protected]> wrote:
On Fri, 3 Aug 2018 16:06:24 +0300
"Yordan Karadzhov (VMware)" <[email protected]> wrote:
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Hi Steven,
Should I send this patch again?Yes, with the updates.
I take this back. I'll do the updates and apply your other patches on top.
And this is what I get when I work on too many projects at once. I already have the update applied to my local tree :-p.
-- Steve