#define READS_BEGUN (info->read) // a read is in progress
-enum pids_item PROCPS_PIDS_logical_end = PROCPS_PIDS_noop + 1;
-enum pids_item PROCPS_PIDS_physical_end = PROCPS_PIDS_noop + 2;
+ // next 2 MUST be kept in sync with highest value enum
+enum pids_item PROCPS_PIDS_logical_end = PROCPS_PIDS_WCHAN_NAME + 1;
+enum pids_item PROCPS_PIDS_physical_end = PROCPS_PIDS_WCHAN_NAME + 2;
// these represent the proc_t fields whose storage cannot be managed
// optimally if they are ever referenced more than once in any stack
if (I->ref_counts[ref_ ## e2]) R->result.strv = NULL; \
else { R->result.strv = P-> x; P-> x = NULL; } }
+setDECL(noop) { (void)I; (void)R; (void)P; return; }
+setDECL(extra) { (void)I; (void)R; (void)P; return; }
REG_set(ADDR_END_CODE, ul_int, end_code)
REG_set(ADDR_KSTK_EIP, ul_int, kstk_eip)
REG_set(ADDR_KSTK_ESP, ul_int, kstk_esp)
REG_set(VSIZE_PGS, ul_int, vsize)
REG_set(WCHAN_ADDR, ul_int, wchan)
setDECL(WCHAN_NAME) { (void)I; R->result.str = strdup(lookup_wchan(P->tid)); }
-setDECL(extra) { (void)I; (void)R; (void)P; return; }
-setDECL(noop) { (void)I; (void)R; (void)P; return; }
-setDECL(logical_end) { (void)I; (void)R; (void)P; return; }
-setDECL(physical_end) { (void)I; (void)R; (void)P; return; }
#undef setDECL
#undef CVT_set
} Item_table[] = {
/* setsfunc oldflags freefunc sortfunc needhist refcount
--------------------- ---------- --------- ------------ -------- ------------- */
+ { RS(noop), 0, NULL, QS(noop), 0, -1 }, // user only, never altered
+ { RS(extra), 0, NULL, QS(ull_int), 0, -1 }, // user only, reset to zero
{ RS(ADDR_END_CODE), f_stat, NULL, QS(ul_int), 0, -1 },
{ RS(ADDR_KSTK_EIP), f_stat, NULL, QS(ul_int), 0, -1 },
{ RS(ADDR_KSTK_ESP), f_stat, NULL, QS(ul_int), 0, -1 },
{ RS(VSIZE_PGS), f_stat, NULL, QS(ul_int), 0, -1 },
{ RS(WCHAN_ADDR), f_stat, NULL, QS(ul_int), 0, -1 },
{ RS(WCHAN_NAME), 0, FF(str), QS(str), 0, -1 }, // oldflags: tid already free
- { RS(extra), 0, NULL, QS(ull_int), 0, -1 },
- { RS(noop), 0, NULL, QS(noop), 0, -1 },
- { RS(logical_end), 0, NULL, QS(noop), 0, -1 },
- { RS(physical_end), 0, NULL, QS(noop), 0, -1 }
+ // dummy entry never referenced ( makes future additions 'comma' worry free )...
+ { NULL, 0, NULL, NULL, 0, -1 }
};
#undef RS
int i;
for (i = 0; i < depth; i++) {
- if (p->item < PROCPS_PIDS_noop) {
- if (Item_table[p->item].freefunc)
- Item_table[p->item].freefunc(p);
+ if (p->item >= PROCPS_PIDS_logical_end)
+ break;
+ if (Item_table[p->item].freefunc)
+ Item_table[p->item].freefunc(p);
+ if (p->item > PROCPS_PIDS_noop)
p->result.ull_int = 0;
- }
++p;
}
} // end: cleanup_stack
// a pids_item is currently unsigned, but we'll protect our future
if (items[i] < 0)
return -1;
- if (items[i] > PROCPS_PIDS_noop) {
+ if (items[i] >= PROCPS_PIDS_logical_end) {
return -1;
}
}
* alloc_stacks():
*
* Allocate and initialize one or more stacks each of which is anchored in an
- * associated pids_stack structure (which may include extra user space).
+ * associated pids_stack structure.
*
* All such stacks will will have their result structures properly primed with
* 'items', while the result itself will be zeroed.
if (info == NULL || stacks == NULL)
return NULL;
// a pids_item is currently unsigned, but we'll protect our future
- if (sort < 0 || sort > PROCPS_PIDS_noop)
+ if (sort < 0 || sort >= PROCPS_PIDS_logical_end)
return NULL;
if (order != PROCPS_SORT_ASCEND && order != PROCPS_SORT_DESCEND)
return NULL;
++offset;
if (offset >= info->curitems)
return NULL;
- if (p->item > PROCPS_PIDS_noop)
+ if (p->item >= PROCPS_PIDS_logical_end)
return NULL;
++p;
}