top: a small safeguard added to the ATEOJ_RPTHSH logic

If a hash results report was output (via ATEOJ_RPTHSH)
a portion is devoted to occupied table entries ordered
by depth. There is a possibility that some depths will
not be found among existing occupied table entries and
to avoid any confusion probably should not be printed.

[ to illustrate the potential for confusion prior to ]
[ this patch, force a very small table size (like 8) ]
[ and then arrange to trigger the end-of-job report. ]

So this patch ensures only 'in use' entries are shown.

[ admittedly, all of the remaining logic in the loop ]
[ could/should be subordinate to this new 'if' test, ]
[ but we will keep the change to a minimum. besides, ]
[ there's no harm subtracting/adding a zero numdepth ]
[ especially since the chance of a zero is very low. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-10-19 00:00:00 -05:00 committed by Craig Small
parent cb13448179
commit 2a5b8658d2

View File

@ -532,7 +532,7 @@ static void bye_bye (const char *str) {
for (pop = total_occupied, cross_foot = 0; maxdepth; maxdepth--) {
for (i = 0, numdepth = 0; i < HHASH_SIZ; i++)
if (depths[i] == maxdepth) ++numdepth;
fprintf(stderr,
if (numdepth) fprintf(stderr,
"\t %5d (%3d%%) hash table entries at depth %d\n"
, numdepth, (numdepth * 100) / total_occupied, maxdepth + 1);
pop -= numdepth;