From a9ac3faa444097fcf81fe057a4b363d17d6e6a43 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 13 Jul 2020 00:00:00 -0500 Subject: [PATCH] library: show allowable range in relative enum warning This patch just trades the 'typestr' for the much more meaningful 'valid range' when a relative enum has been deemed invalid under that XTRA_PROCPS_DEBUG provision. [ and we'll also make one comment a bit more generic ] Signed-off-by: Jim Warner --- proc/diskstats.c | 6 +++--- proc/meminfo.c | 6 +++--- proc/pids.c | 6 +++--- proc/slabinfo.c | 6 +++--- proc/stat.c | 6 +++--- proc/vmstat.c | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/proc/diskstats.c b/proc/diskstats.c index 48b43c3a..4122a239 100644 --- a/proc/diskstats.c +++ b/proc/diskstats.c @@ -948,7 +948,7 @@ PROCPS_EXPORT struct diskstats_stack **procps_diskstats_sort ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct diskstats_result *xtra_diskstats_get ( @@ -989,8 +989,8 @@ PROCPS_EXPORT struct diskstats_result *xtra_diskstats_val ( for (i = 0; stack->head[i].item < DISKSTATS_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str; diff --git a/proc/meminfo.c b/proc/meminfo.c index 73035877..f5155595 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -925,7 +925,7 @@ PROCPS_EXPORT struct meminfo_stack *procps_meminfo_select ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct meminfo_result *xtra_meminfo_get ( @@ -965,8 +965,8 @@ PROCPS_EXPORT struct meminfo_result *xtra_meminfo_val ( for (i = 0; stack->head[i].item < MEMINFO_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str; diff --git a/proc/pids.c b/proc/pids.c index 0822a133..c05743d7 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -1502,7 +1502,7 @@ PROCPS_EXPORT struct pids_stack **procps_pids_sort ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct pids_result *xtra_pids_val ( @@ -1519,8 +1519,8 @@ PROCPS_EXPORT struct pids_result *xtra_pids_val ( for (i = 0; stack->head[i].item < PIDS_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str; diff --git a/proc/slabinfo.c b/proc/slabinfo.c index ff04ec80..2bdb663f 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -965,7 +965,7 @@ PROCPS_EXPORT struct slabinfo_stack **procps_slabinfo_sort ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct slabinfo_result *xtra_slabinfo_get ( @@ -1005,8 +1005,8 @@ PROCPS_EXPORT struct slabinfo_result *xtra_slabinfo_val ( for (i = 0; stack->head[i].item < SLABINFO_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str; diff --git a/proc/stat.c b/proc/stat.c index 93b23bf4..9c5b2012 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -1152,7 +1152,7 @@ PROCPS_EXPORT struct stat_stack **procps_stat_sort ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct stat_result *xtra_stat_get ( @@ -1192,8 +1192,8 @@ PROCPS_EXPORT struct stat_result *xtra_stat_val ( for (i = 0; stack->head[i].item < STAT_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str; diff --git a/proc/vmstat.c b/proc/vmstat.c index 36a89232..5118dd06 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -1355,7 +1355,7 @@ PROCPS_EXPORT struct vmstat_stack *procps_vmstat_select ( * * It's used only when: * 1) the 'XTRA_PROCPS_DEBUG' has been defined, or - * 2) the '#include ' used + * 2) an #include of 'xtra-procps-debug.h' is used */ PROCPS_EXPORT struct vmstat_result *xtra_vmstat_get ( @@ -1395,8 +1395,8 @@ PROCPS_EXPORT struct vmstat_result *xtra_vmstat_val ( for (i = 0; stack->head[i].item < VMSTAT_logical_end; i++) ; if (relative_enum < 0 || relative_enum >= i) { - fprintf(stderr, "%s line %d: invalid relative_enum = %d, type = %s\n" - , file, lineno, relative_enum, typestr); + fprintf(stderr, "%s line %d: invalid relative_enum = %d, valid range = 0-%d\n" + , file, lineno, relative_enum, i-1); return NULL; } str = Item_table[stack->head[relative_enum].item].type2str;