kernel-shark: Fixing the fix in ksmodel_zoom
PATCH 1/1 kernel-shark: Fixing the fix in ksmodel_zoom
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) <[email protected]>
Fixes bedcff1165 ("kernel-shark: Fix a bug in ksmodel_zoom")
Signed-off-by Yordan Karadzhov <[email protected]>
--- kernel-shark/src/libkshark-model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/libkshark-model.c +1 -1
@@ -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;/*
Signature · 1 line
2.20.1