library: eliminate one potential source of human error

There's a huge toe-stubber awaiting future maintenance
as reflected in that commit below which deals with the
addition of new enumerators to the Item_table. Namely,
whenever the table is grown, one must remember to also
change that existing 'logical_end' enumerator's value.

Well, not anymore! Since that MAXTABLE macro was added
to the procps-private.h header we can now also exploit
it so a 'logical_end' automatically tracks table size.

This change also renders some code associated with the
ITEMTABLE_DEBUG #define unnecessary. So it's gone too.

Reference(s):
. 08/2016, add new enumerators
commit 09e1886c9e
. 08/2020, added MAXTABLE macro
commit c865b06c30
. 08/2020, introduced ITEMTABLE_DEBUG
commit 92d0297e1e

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2020-08-22 00:00:00 -05:00
committed by Craig Small
parent fa51c2524a
commit 2c1973d64c
6 changed files with 6 additions and 36 deletions

View File

@@ -361,7 +361,7 @@ static struct {
#ifdef ENFORCE_LOGICAL
enum stat_item STAT_TIC_highest = STAT_TIC_DELTA_GUEST_NICE;
#endif
enum stat_item STAT_logical_end = STAT_SYS_DELTA_PROC_RUNNING + 1;
enum stat_item STAT_logical_end = MAXTABLE(Item_table);
#undef setNAME
#undef srtNAME
@@ -875,11 +875,6 @@ PROCPS_EXPORT int procps_stat_new (
failed = 1;
}
}
if (i != STAT_logical_end) {
fprintf(stderr, "%s: STAT_logical_end is %d, expected %d\n"
, __FILE__, STAT_logical_end, i);
failed = 1;
}
if (failed) _Exit(EXIT_FAILURE);
#endif