From 7d20df9ef0c5e34b842268c57891fbe218d061d7 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 8 Aug 2016 11:22:33 -0500 Subject: [PATCH] library: if the VAL type is wrong still return a value Rather than return a 0 result for all VAL type errors, return what would have been without validation active. This will enable a program like pgrep to still print a result even though it used some incorrect type member. With this commit, our VAL macro validations logic will behave in exactly the same way as the GET validations. While warning messages may be issued, except for a bad enumerator, values will always be returned to callers. Signed-off-by: Jim Warner --- proc/diskstats.c | 1 - proc/meminfo.c | 1 - proc/pids.c | 1 - proc/slabinfo.c | 1 - proc/stat.c | 1 - proc/vmstat.c | 1 - 6 files changed, 6 deletions(-) diff --git a/proc/diskstats.c b/proc/diskstats.c index 55125ff8..c72369c2 100644 --- a/proc/diskstats.c +++ b/proc/diskstats.c @@ -1036,7 +1036,6 @@ PROCPS_EXPORT struct diskstats_result *xtra_diskstats_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_diskstats_val diff --git a/proc/meminfo.c b/proc/meminfo.c index 42e1f9a7..ee8ecbe3 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -908,7 +908,6 @@ PROCPS_EXPORT struct meminfo_result *xtra_meminfo_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_meminfo_val diff --git a/proc/pids.c b/proc/pids.c index f8816a0d..96afbc78 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -1525,7 +1525,6 @@ PROCPS_EXPORT struct pids_result *xtra_pids_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_pids_val diff --git a/proc/slabinfo.c b/proc/slabinfo.c index a1989ff2..afad3086 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -1065,7 +1065,6 @@ PROCPS_EXPORT struct slabinfo_result *xtra_slabinfo_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_slabinfo_val diff --git a/proc/stat.c b/proc/stat.c index 45ebcde4..5c3f3b87 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -1183,7 +1183,6 @@ PROCPS_EXPORT struct stat_result *xtra_stat_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_stat_val diff --git a/proc/vmstat.c b/proc/vmstat.c index 3f6cb8ad..6cf8c52d 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -1304,7 +1304,6 @@ PROCPS_EXPORT struct vmstat_result *xtra_vmstat_val ( if (str[0] && (strcmp(typestr, str))) { fprintf(stderr, "%s line %d: was %s, expected %s\n", file, lineno, typestr, str); - return NULL; } return &stack->head[relative_enum]; } // end: xtra_vmstat_val -- 2.40.0