Message ID | 20190422123753.3821-1-ykaradzhov@vmware.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 93ee67da48016b9f645748eb5961ff890ee33937 |
Delegated to: | Steven Rostedt |
Headers | show |
Series | kernel-shark: Fixing the fix in ksmodel_zoom | expand |
diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index 29676c7..978cd70 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -649,7 +649,7 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo, * Avoid overzooming. If needed, adjust the Scale factor to a the value * which provides bin_size >= 5. */ - if (zoom_in && (int) range * (1. - r) < histo->n_bins * 5) + if (zoom_in && (size_t) (range * (1. - r)) < histo->n_bins * 5) r = 1. - (histo->n_bins * 5.) / range; /*
if (zoom_in && (int) range * (1. - r) < histo->n_bins * 5) The line above has two bugs: - 64 bit type (size_t) is casted to 32 bit (int) - Type cast operator has a higher precedence than the multiplication operator, hence "(int) range * (1. - r)" is a floating point number Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Fixes: bedcff1165 ("kernel-shark: Fix a bug in ksmodel_zoom") Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark/src/libkshark-model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)