From fab37662efe92650063a45e6b20eda09afe07e14 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 1 Sep 2018 00:00:00 -0500 Subject: [PATCH] library: refactor the XTRA_PROCPS_DEBUG implementation If we ever were to eliminate the procps.h header file, as discussed in the thread referenced below, then that would impair the current XTRA_PROCPS_DEBUG provisions. The only remaining way to verify result types would be to explicitly include that . So, this commit will once again enable the ./configure provision for defining the -DXTRA_PROCPS_DEBUG option. Reference(s): https://www.freelists.org/post/procps/newlib-Qualys-patches,6 Signed-off-by: Jim Warner --- proc/diskstats.h | 4 +++ proc/meminfo.h | 4 +++ proc/pids.h | 4 +++ proc/procps.h | 4 --- proc/slabinfo.h | 4 +++ proc/stat.h | 4 +++ proc/vmstat.h | 4 +++ proc/xtra-procps-debug.h | 61 +++++++++++++++++++--------------------- 8 files changed, 53 insertions(+), 36 deletions(-) diff --git a/proc/diskstats.h b/proc/diskstats.h index dd718910..278b5b17 100644 --- a/proc/diskstats.h +++ b/proc/diskstats.h @@ -126,6 +126,10 @@ struct diskstats_stack **procps_diskstats_sort ( enum diskstats_item sortitem, enum diskstats_sort_order order); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/meminfo.h b/proc/meminfo.h index 238221c6..eddf1ca6 100644 --- a/proc/meminfo.h +++ b/proc/meminfo.h @@ -171,6 +171,10 @@ struct meminfo_stack *procps_meminfo_select ( enum meminfo_item *items, int numitems); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/pids.h b/proc/pids.h index d1414efc..9b250fb5 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -234,6 +234,10 @@ struct pids_stack **procps_pids_sort ( enum pids_item sortitem, enum pids_sort_order order); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/procps.h b/proc/procps.h index 0b8da284..53033e98 100644 --- a/proc/procps.h +++ b/proc/procps.h @@ -34,8 +34,4 @@ #define ESC_STRETCH 1 // since we mangle to '?' this is 1 (would be 4 for octal escapes) int escape_str(char *__restrict dst, const char *__restrict src, int bufsize, int *maxcells); -#ifdef XTRA_PROCPS_DEBUG -#include -#endif - #endif diff --git a/proc/slabinfo.h b/proc/slabinfo.h index 7454515c..7f735af7 100644 --- a/proc/slabinfo.h +++ b/proc/slabinfo.h @@ -130,6 +130,10 @@ struct slabinfo_stack **procps_slabinfo_sort ( enum slabinfo_item sortitem, enum slabinfo_sort_order order); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/stat.h b/proc/stat.h index 5682773c..b40d4e13 100644 --- a/proc/stat.h +++ b/proc/stat.h @@ -154,6 +154,10 @@ struct stat_stack **procps_stat_sort ( enum stat_item sortitem, enum stat_sort_order order); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/vmstat.h b/proc/vmstat.h index 4db14b09..713f8770 100644 --- a/proc/vmstat.h +++ b/proc/vmstat.h @@ -308,6 +308,10 @@ struct vmstat_stack *procps_vmstat_select ( enum vmstat_item *items, int numitems); + +#ifdef XTRA_PROCPS_DEBUG +# include +#endif #ifdef __cplusplus } #endif diff --git a/proc/xtra-procps-debug.h b/proc/xtra-procps-debug.h index e8400ff8..15746f04 100644 --- a/proc/xtra-procps-debug.h +++ b/proc/xtra-procps-debug.h @@ -18,15 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef XTRA_PROCPS_DEBUG_H -#define XTRA_PROCPS_DEBUG_H - #include // --- DISKSTATS ------------------------------------------ -#ifdef DISKSTATS_GET -#undef DISKSTATS_GET +#if defined(PROCPS_DISKSTATS_H) && !defined(PROCPS_DISKSTATS_H_DEBUG) +#define PROCPS_DISKSTATS_H_DEBUG + struct diskstats_result *xtra_diskstats_get ( struct diskstats_info *info, const char *name, @@ -35,14 +33,12 @@ struct diskstats_result *xtra_diskstats_get ( const char *file, int lineno); +# undef DISKSTATS_GET #define DISKSTATS_GET( info, name, actual_enum, type ) ( { \ struct diskstats_result *r; \ r = xtra_diskstats_get(info, name, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \ r ? r->result . type : 0; } ) -#endif // . . . . . . . . . . -#ifdef DISKSTATS_VAL -#undef DISKSTATS_VAL struct diskstats_result *xtra_diskstats_val ( int relative_enum, const char *typestr, @@ -51,6 +47,7 @@ struct diskstats_result *xtra_diskstats_val ( const char *file, int lineno); +# undef DISKSTATS_VAL #define DISKSTATS_VAL( relative_enum, type, stack, info ) ( { \ struct diskstats_result *r; \ r = xtra_diskstats_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ @@ -59,8 +56,9 @@ struct diskstats_result *xtra_diskstats_val ( // --- MEMINFO -------------------------------------------- -#ifdef MEMINFO_GET -#undef MEMINFO_GET +#if defined(PROCPS_MEMINFO_H) && !defined(PROCPS_MEMINFO_H_DEBUG) +#define PROCPS_MEMINFO_H_DEBUG + struct meminfo_result *xtra_meminfo_get ( struct meminfo_info *info, enum meminfo_item actual_enum, @@ -68,14 +66,12 @@ struct meminfo_result *xtra_meminfo_get ( const char *file, int lineno); +# undef MEMINFO_GET #define MEMINFO_GET( info, actual_enum, type ) ( { \ struct meminfo_result *r; \ r = xtra_meminfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \ r ? r->result . type : 0; } ) -#endif // . . . . . . . . . . -#ifdef MEMINFO_VAL -#undef MEMINFO_VAL struct meminfo_result *xtra_meminfo_val ( int relative_enum, const char *typestr, @@ -84,6 +80,7 @@ struct meminfo_result *xtra_meminfo_val ( const char *file, int lineno); +# undef MEMINFO_VAL #define MEMINFO_VAL( relative_enum, type, stack, info ) ( { \ struct meminfo_result *r; \ r = xtra_meminfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ @@ -92,8 +89,9 @@ struct meminfo_result *xtra_meminfo_val ( // --- PIDS ----------------------------------------------- -#ifdef PIDS_VAL -#undef PIDS_VAL +#if defined(PROCPS_PIDS_H) && !defined(PROCPS_PIDS_H_DEBUG) +#define PROCPS_PIDS_H_DEBUG + struct pids_result *xtra_pids_val ( int relative_enum, const char *typestr, @@ -102,6 +100,7 @@ struct pids_result *xtra_pids_val ( const char *file, int lineno); +# undef PIDS_VAL #define PIDS_VAL( relative_enum, type, stack, info ) ( { \ struct pids_result *r; \ r = xtra_pids_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ @@ -110,8 +109,9 @@ struct pids_result *xtra_pids_val ( // --- SLABINFO ------------------------------------------- -#ifdef SLABINFO_GET -#undef SLABINFO_GET +#if defined(PROCPS_SLABINFO_H) && !defined(PROCPS_SLABINFO_H_DEBUG) +#define PROCPS_SLABINFO_H_DEBUG + struct slabinfo_result *xtra_slabinfo_get ( struct slabinfo_info *info, enum slabinfo_item actual_enum, @@ -119,14 +119,12 @@ struct slabinfo_result *xtra_slabinfo_get ( const char *file, int lineno); +# undef SLABINFO_GET #define SLABINFO_GET( info, actual_enum, type ) ( { \ struct slabinfo_result *r; \ r = xtra_slabinfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \ r ? r->result . type : 0; } ) -#endif // . . . . . . . . . . -#ifdef SLABINFO_VAL -#undef SLABINFO_VAL struct slabinfo_result *xtra_slabinfo_val ( int relative_enum, const char *typestr, @@ -135,6 +133,7 @@ struct slabinfo_result *xtra_slabinfo_val ( const char *file, int lineno); +# undef SLABINFO_VAL #define SLABINFO_VAL( relative_enum, type, stack, info ) ( { \ struct slabinfo_result *r; \ r = xtra_slabinfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ @@ -143,8 +142,9 @@ struct slabinfo_result *xtra_slabinfo_val ( // --- STAT ----------------------------------------------- -#ifdef STAT_GET -#undef STAT_GET +#if defined(PROCPS_STAT_H) && !defined(PROCPS_STAT_H_DEBUG) +#define PROCPS_STAT_H_DEBUG + struct stat_result *xtra_stat_get ( struct stat_info *info, enum stat_item actual_enum, @@ -152,14 +152,12 @@ struct stat_result *xtra_stat_get ( const char *file, int lineno); +# undef STAT_GET #define STAT_GET( info, actual_enum, type ) ( { \ struct stat_result *r; \ r = xtra_stat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \ r ? r->result . type : 0; } ) -#endif // . . . . . . . . . . -#ifdef STAT_VAL -#undef STAT_VAL struct stat_result *xtra_stat_val ( int relative_enum, const char *typestr, @@ -168,6 +166,7 @@ struct stat_result *xtra_stat_val ( const char *file, int lineno); +# undef STAT_VAL #define STAT_VAL( relative_enum, type, stack, info ) ( { \ struct stat_result *r; \ r = xtra_stat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ @@ -176,8 +175,9 @@ struct stat_result *xtra_stat_val ( // --- VMSTAT --------------------------------------------- -#ifdef VMSTAT_GET -#undef VMSTAT_GET +#if defined(PROCPS_VMSTAT_H) && !defined(PROCPS_VMSTAT_H_DEBUG) +#define PROCPS_VMSTAT_H_DEBUG + struct vmstat_result *xtra_vmstat_get ( struct vmstat_info *info, enum vmstat_item actual_enum, @@ -185,14 +185,12 @@ struct vmstat_result *xtra_vmstat_get ( const char *file, int lineno); +# undef VMSTAT_GET #define VMSTAT_GET( info, actual_enum, type ) ( { \ struct vmstat_result *r; \ r = xtra_vmstat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \ r ? r->result . type : 0; } ) -#endif // . . . . . . . . . . -#ifdef VMSTAT_VAL -#undef VMSTAT_VAL struct vmstat_result *xtra_vmstat_val ( int relative_enum, const char *typestr, @@ -201,10 +199,9 @@ struct vmstat_result *xtra_vmstat_val ( const char *file, int lineno); +# undef VMSTAT_VAL #define VMSTAT_VAL( relative_enum, type, stack, info ) ( { \ struct vmstat_result *r; \ r = xtra_vmstat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \ r ? r->result . type : 0; } ) #endif // . . . . . . . . . . - -#endif // end: XTRA_PROCPS_DEBUG_H