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:
parent
fa51c2524a
commit
2c1973d64c
@ -270,7 +270,7 @@ static struct {
|
|||||||
|
|
||||||
/* please note,
|
/* please note,
|
||||||
* this enum MUST be 1 greater than the highest value of any enum */
|
* this enum MUST be 1 greater than the highest value of any enum */
|
||||||
enum diskstats_item DISKSTATS_logical_end = DISKSTATS_DELTA_WEIGHTED_TIME + 1;
|
enum diskstats_item DISKSTATS_logical_end = MAXTABLE(Item_table);
|
||||||
|
|
||||||
#undef setNAME
|
#undef setNAME
|
||||||
#undef srtNAME
|
#undef srtNAME
|
||||||
@ -725,11 +725,6 @@ PROCPS_EXPORT int procps_diskstats_new (
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != DISKSTATS_logical_end) {
|
|
||||||
fprintf(stderr, "%s: DISKSTATS_logical_end is %d, expected %d\n"
|
|
||||||
, __FILE__, DISKSTATS_logical_end, i);
|
|
||||||
failed = 1;
|
|
||||||
}
|
|
||||||
if (failed) _Exit(EXIT_FAILURE);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ static struct {
|
|||||||
|
|
||||||
/* please note,
|
/* please note,
|
||||||
* this enum MUST be 1 greater than the highest value of any enum */
|
* this enum MUST be 1 greater than the highest value of any enum */
|
||||||
enum meminfo_item MEMINFO_logical_end = MEMINFO_SWAP_DELTA_USED + 1;
|
enum meminfo_item MEMINFO_logical_end = MAXTABLE(Item_table);
|
||||||
|
|
||||||
#undef setNAME
|
#undef setNAME
|
||||||
#undef RS
|
#undef RS
|
||||||
@ -808,11 +808,6 @@ PROCPS_EXPORT int procps_meminfo_new (
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != MEMINFO_logical_end) {
|
|
||||||
fprintf(stderr, "%s: MEMINFO_logical_end is %d, expected %d\n"
|
|
||||||
, __FILE__, MEMINFO_logical_end, i);
|
|
||||||
failed = 1;
|
|
||||||
}
|
|
||||||
if (failed) _Exit(EXIT_FAILURE);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ static struct {
|
|||||||
|
|
||||||
/* please note,
|
/* please note,
|
||||||
* this enum MUST be 1 greater than the highest value of any enum */
|
* 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 setNAME
|
||||||
#undef freNAME
|
#undef freNAME
|
||||||
@ -1137,11 +1137,6 @@ PROCPS_EXPORT int procps_pids_new (
|
|||||||
failed = 1;
|
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);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ static struct {
|
|||||||
|
|
||||||
/* please note,
|
/* please note,
|
||||||
* this enum MUST be 1 greater than the highest value of any enum */
|
* this enum MUST be 1 greater than the highest value of any enum */
|
||||||
enum slabinfo_item SLABINFO_logical_end = SLABS_DELTA_SIZE_TOTAL + 1;
|
enum slabinfo_item SLABINFO_logical_end = MAXTABLE(Item_table);
|
||||||
|
|
||||||
#undef setNAME
|
#undef setNAME
|
||||||
#undef srtNAME
|
#undef srtNAME
|
||||||
@ -753,11 +753,6 @@ PROCPS_EXPORT int procps_slabinfo_new (
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != SLABINFO_logical_end) {
|
|
||||||
fprintf(stderr, "%s: SLABINFO_logical_end is %d, expected %d\n"
|
|
||||||
, __FILE__, SLABINFO_logical_end, i);
|
|
||||||
failed = 1;
|
|
||||||
}
|
|
||||||
if (failed) _Exit(EXIT_FAILURE);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ static struct {
|
|||||||
#ifdef ENFORCE_LOGICAL
|
#ifdef ENFORCE_LOGICAL
|
||||||
enum stat_item STAT_TIC_highest = STAT_TIC_DELTA_GUEST_NICE;
|
enum stat_item STAT_TIC_highest = STAT_TIC_DELTA_GUEST_NICE;
|
||||||
#endif
|
#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 setNAME
|
||||||
#undef srtNAME
|
#undef srtNAME
|
||||||
@ -875,11 +875,6 @@ PROCPS_EXPORT int procps_stat_new (
|
|||||||
failed = 1;
|
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);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -898,7 +898,7 @@ static struct {
|
|||||||
|
|
||||||
/* please note,
|
/* please note,
|
||||||
* this enum MUST be 1 greater than the highest value of any enum */
|
* this enum MUST be 1 greater than the highest value of any enum */
|
||||||
enum vmstat_item VMSTAT_logical_end = VMSTAT_DELTA_ZONE_RECLAIM_FAILED + 1;
|
enum vmstat_item VMSTAT_logical_end = MAXTABLE(Item_table);
|
||||||
|
|
||||||
#undef setNAME
|
#undef setNAME
|
||||||
#undef RS
|
#undef RS
|
||||||
@ -1305,11 +1305,6 @@ PROCPS_EXPORT int procps_vmstat_new (
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != VMSTAT_logical_end) {
|
|
||||||
fprintf(stderr, "%s: VMSTAT_logical_end is %d, expected %d\n"
|
|
||||||
, __FILE__, VMSTAT_logical_end, i);
|
|
||||||
failed = 1;
|
|
||||||
}
|
|
||||||
if (failed) _Exit(EXIT_FAILURE);
|
if (failed) _Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user