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