Commit 3e5f3757 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add an enum describing the return values from VSM_StillValid

Use the enum values where VSM_StillValid is used.
parent f2e1f42f
......@@ -873,7 +873,7 @@ do_curses(struct VSM_data *vd, int delay)
}
VSC_C_mgt = VSC_Mgt(vd, &f_mgt);
VSC_C_main = VSC_Main(vd, &f_main);
if (VSM_StillValid(vd, &f_iter) != 1)
if (VSM_valid != VSM_StillValid(vd, &f_iter))
build_pt_list(vd, &f_iter);
now = VTIM_mono();
......
......@@ -139,17 +139,23 @@ int VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf);
* vd = "struct VSM_data *"
*/
int VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf);
enum VSM_valid_e {
VSM_invalid,
VSM_valid,
VSM_similar,
};
enum VSM_valid_e VSM_StillValid(const struct VSM_data *vd,
struct VSM_fantom *vf);
/*
* This is a cheap syscall-less check to see if the fantom is still
* valid. Further checking with VSM_Abandoned() may be a good
* idea.
*
* Return:
* 0: fantom is not valid any more.
* 1: fantom is still the same.
* 2: a fantom with same dimensions exist in same position,
* check class/type/ident
* VSM_invalid: fantom is not valid any more.
* VSM_valid: fantom is still the same.
* VSM_similar: a fantom with same dimensions exist in same position.
*/
int VSM_Get(const struct VSM_data *vd, struct VSM_fantom *vf,
......
......@@ -287,7 +287,7 @@ VSC_Get(struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
if (fantom == NULL)
fantom = &f2;
if (!VSM_StillValid(vd, fantom) &&
if (VSM_invalid == VSM_StillValid(vd, fantom) &&
!VSM_Get(vd, fantom, VSC_CLASS, type, ident))
return (NULL);
return ((void*)fantom->b);
......@@ -470,7 +470,7 @@ VSC_Iter(struct VSM_data *vd, struct VSM_fantom *fantom, VSC_iter_f *func,
struct vsc_pt *pt;
int i;
if (1 != VSM_StillValid(vd, &vsc->iter_fantom)) {
if (VSM_valid != VSM_StillValid(vd, &vsc->iter_fantom)) {
/* Tell app that list will be nuked */
(void)func(priv, NULL);
vsc_build_vf_list(vd);
......
......@@ -131,7 +131,7 @@ vslc_vsm_next(void *cursor)
/* Check VSL fantom and abandonment */
if (*(volatile const uint32_t *)c->next.ptr == VSL_ENDMARKER) {
if (!VSM_StillValid(c->vsm, &c->vf) ||
if (VSM_invalid == VSM_StillValid(c->vsm, &c->vf) ||
VSM_Abandoned(c->vsm))
return (-2);
}
......
......@@ -367,7 +367,7 @@ VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf)
/*--------------------------------------------------------------------*/
int
enum VSM_valid_e
VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
{
struct VSM_fantom f2;
......@@ -375,11 +375,11 @@ VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(vf);
if (!vd->head)
return (0);
return (VSM_invalid);
if (!vd->head->alloc_seq)
return (0);
return (VSM_invalid);
if (vf->priv == vd->head->alloc_seq)
return (1);
return (VSM_valid);
VSM_FOREACH(&f2, vd) {
if (f2.chunk != vf->chunk || f2.b != vf->b || f2.e != vf->e)
continue;
......@@ -390,9 +390,9 @@ VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
if (strcmp(f2.ident, vf->ident))
continue;
vf->priv = vd->head->alloc_seq;
return (2);
return (VSM_similar);
}
return (0);
return (VSM_invalid);
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment