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

@ -518,7 +518,7 @@ static struct {
/* please note,
* this enum MUST be 1 greater than the highest value of any enum */
enum pids_item PIDS_logical_end = PIDS_WCHAN_NAME + 1;
enum pids_item PIDS_logical_end = MAXTABLE(Item_table);
#undef setNAME
#undef freNAME
@ -1137,11 +1137,6 @@ PROCPS_EXPORT int procps_pids_new (
failed = 1;
}
}
if (i != PIDS_logical_end) {
fprintf(stderr, "%s: PIDS_logical_end is %d, expected %d\n"
, __FILE__, PIDS_logical_end, i);
failed = 1;
}
if (failed) _Exit(EXIT_FAILURE);
#endif