Re: [PATCH v2 3/7] kernel-shark-qt: Introduce the visualization model used by the Qt-based KS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 31 Jul 2018 20:51:13 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> > +static void ksmodel_reset_bins(struct kshark_trace_histo *histo,
> > +			       size_t first, size_t last)
> > +{
> > +	/* Reset the content of the bins. */
> > +	memset(&histo->map[first], KS_EMPTY_BIN,
> > +	       (last - first + 1) * sizeof(histo->map[0]));  
> 
> This patch should add a comment here and by KS_EMPTY_BIN stating that
> KS_EMPTY_BIN is expected to be -1, as it is used to reset the entire
> array with memset(). As memset() only updates an array to a single
> byte, that byte must be the same throughout. Which works for zero and
> -1.
> 

Note, I added this too.

-- Steve

diff --git a/kernel-shark-qt/src/libkshark.h b/kernel-shark-qt/src/libkshark.h
index 4860e74d..122c030e 100644
--- a/kernel-shark-qt/src/libkshark.h
+++ b/kernel-shark-qt/src/libkshark.h
@@ -225,7 +225,10 @@ bool kshark_match_pid(struct kshark_context *kshark_ctx,
 bool kshark_match_cpu(struct kshark_context *kshark_ctx,
 		      struct kshark_entry *e, int cpu);
 
-/** Empty bin identifier. */
+/** Empty bin identifier.
+ * KS_EMPTY_BIN is used to reset entire arrays to empty with memset(),
+ * thus it must be -1 for that to work.
+ */
 #define KS_EMPTY_BIN		-1
 
 /** Filtered bin identifier. */



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux