Re: [RFC][PATCH] libtraceeval: Add size checks to insert and query functions

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

 



On Tue, 15 Aug 2023 20:02:34 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> @@ -171,15 +171,23 @@ struct traceeval *traceeval_init(struct traceeval_type *keys,
>  
>  void traceeval_release(struct traceeval *teval);
>  
> -int traceeval_insert(struct traceeval *teval,
> -		     const struct traceeval_data *keys,
> -		     const struct traceeval_data *vals);
> +int traceeval_insert_size(struct traceeval *teval,
> +			  const struct traceeval_data *keys, size_t nr_keys,
> +			  const struct traceeval_data *vals, size_t nr_vals);
> +
> +#define traceeval_insert(teval, keys, vals)				\
> +	traceeval_insert_size(teval, keys, sizeof(keys) / sizeof(keys[0]), \
> +			      vals, sizeof(vals) / sizeof(vals[0]))
>  

I just realized that vals may be NULL, so the above needs to be:

#define traceeval_insert(teval, keys, vals)				\
	traceeval_insert_size(teval, keys, sizeof(keys) / sizeof(keys[0]), \
			      vals, vals ? sizeof(vals) / sizeof(vals[0]) : 0)

-- Steve



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

  Powered by Linux