From 9c0837db32572e922ff4288ed5a21e90f9f945b7 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Wed, 22 Feb 2023 18:30:28 +0100 Subject: [PATCH] Declare parameters with 'const' when possible Signed-off-by: Sebastien GODARD --- mpstat.c | 15 +++++++++------ pr_stats.c | 2 +- rd_stats.c | 2 +- rd_stats.h | 2 +- sa.h | 2 +- sa_common.c | 4 ++-- svg_stats.c | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/mpstat.c b/mpstat.c index 5045e45..9483d27 100644 --- a/mpstat.c +++ b/mpstat.c @@ -663,7 +663,8 @@ unsigned long long get_global_cpu_mpstats(int prev, int curr, *************************************************************************** */ void write_plain_cpu_stats(int dis, unsigned long long deltot_jiffies, int prev, int curr, - char *prev_string, char *curr_string, unsigned char offline_cpu_bitmap[]) + char *prev_string, char *curr_string, + const unsigned char offline_cpu_bitmap[]) { int i; struct stats_cpu *scc, *scp; @@ -777,7 +778,7 @@ void write_plain_cpu_stats(int dis, unsigned long long deltot_jiffies, int prev, *************************************************************************** */ void write_json_cpu_stats(int tab, unsigned long long deltot_jiffies, int prev, int curr, - unsigned char offline_cpu_bitmap[]) + const unsigned char offline_cpu_bitmap[]) { int i, next = FALSE; char cpu_name[16], topology[1024] = ""; @@ -1214,7 +1215,8 @@ void write_node_stats(int dis, unsigned long long deltot_jiffies, int prev, int *************************************************************************** */ void write_plain_isumcpu_stats(int dis, unsigned long long itv, int prev, int curr, - char *prev_string, char *curr_string, unsigned char offline_cpu_bitmap[]) + char *prev_string, char *curr_string, + const unsigned char offline_cpu_bitmap[]) { struct stats_cpu *scc, *scp; struct stats_global_irq *sic, *sip; @@ -1283,7 +1285,7 @@ void write_plain_isumcpu_stats(int dis, unsigned long long itv, int prev, int cu *************************************************************************** */ void write_json_isumcpu_stats(int tab, unsigned long long itv, int prev, int curr, - unsigned char offline_cpu_bitmap[]) + const unsigned char offline_cpu_bitmap[]) { struct stats_cpu *scc, *scp; struct stats_global_irq *sic, *sip; @@ -1403,7 +1405,8 @@ void write_isumcpu_stats(int dis, unsigned long long itv, int prev, int curr, */ void write_plain_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis, unsigned long long itv, int prev, int curr, - char *prev_string, char *curr_string, unsigned char offline_cpu_bitmap[]) + char *prev_string, char *curr_string, + const unsigned char offline_cpu_bitmap[]) { int j = ic_nr, offset, cpu, colwidth[NR_IRQS]; struct stats_irqcpu *p, *q, *p0, *q0; @@ -1542,7 +1545,7 @@ void write_plain_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis, */ void write_json_irqcpu_stats(int tab, struct stats_irqcpu *st_ic[], int ic_nr, unsigned long long itv, int prev, int curr, int type, - unsigned char offline_cpu_bitmap[]) + const unsigned char offline_cpu_bitmap[]) { int j = ic_nr, offset, cpu; struct stats_irqcpu *p, *q, *p0, *q0; diff --git a/pr_stats.c b/pr_stats.c index 8fe04ec..71790b0 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -59,7 +59,7 @@ extern unsigned long avg_count; *************************************************************************** */ void print_hdr_line(char *p_timestamp, struct activity *a, int pos, int iwidth, int vwidth, - unsigned char *offline_bitmap) + const unsigned char *offline_bitmap) { char hline[HEADER_LINE_LEN] = ""; char cfld[16], dfld[16]; diff --git a/rd_stats.c b/rd_stats.c index 77fe96f..2c88d48 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -2803,7 +2803,7 @@ __nr_t read_fchost(struct stats_fchost *st_fc, __nr_t nr_alloc) *************************************************************************** */ int read_softnet(struct stats_softnet *st_softnet, __nr_t nr_alloc, - unsigned char online_cpu_bitmap[]) + const unsigned char online_cpu_bitmap[]) { FILE *fp; struct stats_softnet *st_softnet_i, st_softnet_read; diff --git a/rd_stats.h b/rd_stats.h index d23fb75..f596a4b 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -878,7 +878,7 @@ __nr_t read_filesystem __nr_t read_fchost (struct stats_fchost *, __nr_t); int read_softnet - (struct stats_softnet *, __nr_t, unsigned char []); + (struct stats_softnet *, __nr_t, const unsigned char []); __nr_t read_psicpu (struct stats_psi_cpu *); __nr_t read_psiio diff --git a/sa.h b/sa.h index fa12f12..088c344 100644 --- a/sa.h +++ b/sa.h @@ -1642,6 +1642,6 @@ void set_hdr_rectime void set_record_timestamp_string (uint64_t, char *, char *, int, struct tstamp_ext *); void swap_struct - (unsigned int [], void *, int); + (const unsigned int [], void *, int); #endif /* SOURCE_SADC undefined */ #endif /* _SA_H */ diff --git a/sa_common.c b/sa_common.c index d7fadd2..6118957 100644 --- a/sa_common.c +++ b/sa_common.c @@ -1255,7 +1255,7 @@ void select_default_activity(struct activity *act[]) * @is64bit TRUE if data come from a 64-bit machine. *************************************************************************** */ -void swap_struct(unsigned int types_nr[], void *ps, int is64bit) +void swap_struct(const unsigned int types_nr[], void *ps, int is64bit) { int i; uint64_t *x; @@ -1315,7 +1315,7 @@ void swap_struct(unsigned int types_nr[], void *ps, int is64bit) * -1 if an error has been encountered, or 0 otherwise. *************************************************************************** */ -int remap_struct(unsigned int gtypes_nr[], unsigned int ftypes_nr[], +int remap_struct(const unsigned int gtypes_nr[], const unsigned int ftypes_nr[], void *ps, unsigned int f_size, unsigned int g_size, size_t b_size) { int d; diff --git a/svg_stats.c b/svg_stats.c index fb89e62..bb2082d 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -90,7 +90,7 @@ unsigned int svg_colors[SVG_COL_PALETTE_NR][SVG_COL_PALETTE_SIZE] = * @spmax Array containing the possible new max values for current activity. *************************************************************************** */ -void save_extrema(unsigned int types_nr[], void *cs, void *ps, unsigned long long itv, +void save_extrema(const unsigned int types_nr[], void *cs, void *ps, unsigned long long itv, double *spmin, double *spmax, int g_fields[]) { unsigned long long *lluc, *llup; -- 2.40.0