Skip to contentSkip to conversation

kernel-shark-qt: Handle the case when the range of the model is too small

PATCH In review Yordan Karadzhov 2 participants 2 messages Jan 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-shark-qt: Handle the case when the range of the model is too small

The size of the bin must be equal or greater than 1, hence the range must be equal or greater than the number of bins. When this condition is not satisfied, the range has to be extended, instead of just leaving the model unset.

---
 kernel-shark-qt/src/libkshark-model.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel-shark-qt/src/libkshark-model.c +4 -2
index 76e2940..2094795 100644
@@ -102,8 +102,10 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
 	struct kshark_entry *last;
 
 	/* The size of the bin must be >= 1, hence the range must be >= n. */
-	if (n == 0 || range < n)
-		return;
+	if (n == 0 || range < n) {
+		range = n;
+		max = min + n;
+	}
 
 	/*
 	 * If the number of bins changes, allocate memory for the descriptor of
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · On Tue, 15 Jan 2019 12:18:57 +0200 Yordan Karadzhov <[email protected]>…

The size of the bin must be equal or greater than 1, hence the range must be equal or greater than the number of bins. When this condition is not satisfied, the range has to be extended, instead of just leaving the model unset.

You forgot to add:

Fixes f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")

;-)

-- Steve

Quoted 22 lines
---
 kernel-shark-qt/src/libkshark-model.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel-shark-qt/src/libkshark-model.c +4 -2
index 76e2940..2094795 100644
@@ -102,8 +102,10 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
 	struct kshark_entry *last;
 
 	/* The size of the bin must be >= 1, hence the range must be >= n. */
-	if (n == 0 || range < n)
-		return;
+	if (n == 0 || range < n) {
+		range = n;
+		max = min + n;
+	}
 
 	/*
 	 * If the number of bins changes, allocate memory for the descriptor of