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 commit09e1886c9e
. 08/2020, added MAXTABLE macro commitc865b06c30
. 08/2020, introduced ITEMTABLE_DEBUG commit92d0297e1e
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user