Commit e68819f4 authored by Nils Goroll's avatar Nils Goroll

Change VCL_Check signature to return enum vcl_check

parent 437171de
...@@ -312,7 +312,15 @@ int VSL_ResetCursor(const struct VSL_cursor *c); ...@@ -312,7 +312,15 @@ int VSL_ResetCursor(const struct VSL_cursor *c);
* -1: Operation not supported * -1: Operation not supported
*/ */
int VSL_Check(const struct VSL_cursor *c, const struct VSLC_ptr *ptr); enum vsl_check {
vsl_check_e_notsupp = -1,
vsl_check_e_inval = 0,
vsl_check_warn = 1,
vsl_check_valid = 2
};
enum vsl_check
VSL_Check(const struct VSL_cursor *c, const struct VSLC_ptr *ptr);
/* /*
* Check if the VSLC_ptr structure points to a value that is still * Check if the VSLC_ptr structure points to a value that is still
* valid: * valid:
......
...@@ -39,7 +39,8 @@ void vsl_vbm_bitclr(int bit, void *priv); ...@@ -39,7 +39,8 @@ void vsl_vbm_bitclr(int bit, void *priv);
typedef void vslc_delete_f(const struct VSL_cursor *); typedef void vslc_delete_f(const struct VSL_cursor *);
typedef int vslc_next_f(const struct VSL_cursor *); typedef int vslc_next_f(const struct VSL_cursor *);
typedef int vslc_reset_f(const struct VSL_cursor *); typedef int vslc_reset_f(const struct VSL_cursor *);
typedef int vslc_check_f(const struct VSL_cursor *, const struct VSLC_ptr *); typedef enum vsl_check vslc_check_f(const struct VSL_cursor *,
const struct VSLC_ptr *);
struct vslc_tbl { struct vslc_tbl {
unsigned magic; unsigned magic;
......
...@@ -91,7 +91,7 @@ vslc_vsm_delete(const struct VSL_cursor *cursor) ...@@ -91,7 +91,7 @@ vslc_vsm_delete(const struct VSL_cursor *cursor)
* written * written
*/ */
static int static enum vsl_check v_matchproto_(vslc_check_f)
vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr)
{ {
const struct vslc_vsm *c; const struct vslc_vsm *c;
...@@ -101,25 +101,25 @@ vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) ...@@ -101,25 +101,25 @@ vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr)
assert(&c->cursor == cursor); assert(&c->cursor == cursor);
if (ptr->ptr == NULL) if (ptr->ptr == NULL)
return (0); return (vsl_check_e_inval);
dist = c->head->segment_n - ptr->priv; dist = c->head->segment_n - ptr->priv;
if (dist >= VSL_SEGMENTS - 2) if (dist >= VSL_SEGMENTS - 2)
/* Too close to continue */ /* Too close to continue */
return (0); return (vsl_check_e_inval);
if (dist >= VSL_SEGMENTS - 4) if (dist >= VSL_SEGMENTS - 4)
/* Warning level */ /* Warning level */
return (1); return (vsl_check_warn);
/* Safe */ /* Safe */
return (2); return (vsl_check_valid);
} }
static int static int
vslc_vsm_next(const struct VSL_cursor *cursor) vslc_vsm_next(const struct VSL_cursor *cursor)
{ {
struct vslc_vsm *c; struct vslc_vsm *c;
int i; enum vsl_check i;
uint32_t t; uint32_t t;
CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC);
...@@ -127,7 +127,7 @@ vslc_vsm_next(const struct VSL_cursor *cursor) ...@@ -127,7 +127,7 @@ vslc_vsm_next(const struct VSL_cursor *cursor)
while (1) { while (1) {
i = vslc_vsm_check(&c->cursor, &c->next); i = vslc_vsm_check(&c->cursor, &c->next);
if (i <= 0) { if (i < vsl_check_warn) {
if (VSM_StillValid(c->vsm, &c->vf) != VSM_valid) if (VSM_StillValid(c->vsm, &c->vf) != VSM_valid)
return (-2); /* VSL abandoned */ return (-2); /* VSL abandoned */
else else
...@@ -489,13 +489,13 @@ VSL_Next(const struct VSL_cursor *cursor) ...@@ -489,13 +489,13 @@ VSL_Next(const struct VSL_cursor *cursor)
return ((tbl->next)(cursor)); return ((tbl->next)(cursor));
} }
int enum vsl_check
VSL_Check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) VSL_Check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr)
{ {
const struct vslc_tbl *tbl; const struct vslc_tbl *tbl;
CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC);
if (tbl->check == NULL) if (tbl->check == NULL)
return (-1); return (vsl_check_e_notsupp);
return ((tbl->check)(cursor, ptr)); return ((tbl->check)(cursor, ptr));
} }
...@@ -435,7 +435,7 @@ vtx_append(struct VSLQ *vslq, struct vtx *vtx, const struct VSLC_ptr *start, ...@@ -435,7 +435,7 @@ vtx_append(struct VSLQ *vslq, struct vtx *vtx, const struct VSLC_ptr *start,
return; return;
AN(start); AN(start);
if (VSL_Check(vslq->c, start) == 2 && if (VSL_Check(vslq->c, start) == vsl_check_valid &&
!VTAILQ_EMPTY(&vtx->shmchunks_free)) { !VTAILQ_EMPTY(&vtx->shmchunks_free)) {
/* Shmref it */ /* Shmref it */
chunk = VTAILQ_FIRST(&vtx->shmchunks_free); chunk = VTAILQ_FIRST(&vtx->shmchunks_free);
......
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