On Wed, Sep 03, 2025 at 03:53:21PM +0530, Jahan Murudi wrote: > diff --git a/tools/xentop/pcpu.c b/tools/xentop/pcpu.c > new file mode 100644 > index 0000000000..cdb4cb2131 > --- /dev/null > +++ b/tools/xentop/pcpu.c [..] > +/* Accessor functions for xentop.c */ > +int get_pcpu_count(void) > +{ > + return allocated_pcpus; > +} > + > +float get_pcpu_usage(int cpu_index)
You could use `size_t` instead of `int` for the `cpu_index`, and then, no need to check for negatives. `allocated_pcpus` could also be `size_t` or `unsigned int`, since "0" mean not available, we don't need "-1" or other negative numbers. > +{ > + if (!pcpu_stats || cpu_index < 0 || cpu_index >= allocated_pcpus) { > + return 0.0; > + } > + return pcpu_stats[cpu_index].usage_pct; > +} Thanks, -- Anthony PERARD