Refactor: relax match in take_obj_notnull.cocci to catch more cases

We have some places in the code where the verbatim "take obj" semantics do not
have setting the pointer to NULL immediately following.
parent 52a6d38c
......@@ -345,10 +345,9 @@ vdp_gunzip_fini(struct vdp_ctx *vdc, void **priv)
struct vgz *vg;
(void)vdc;
CAST_OBJ_NOTNULL(vg, *priv, VGZ_MAGIC);
TAKE_OBJ_NOTNULL(vg, priv, VGZ_MAGIC);
AN(vg->m_buf);
(void)VGZ_Destroy(&vg);
*priv = NULL;
return (0);
}
......
......@@ -54,13 +54,13 @@ vrg_range_fini(struct vdp_ctx *vdc, void **priv)
struct vrg_priv *vrg_priv;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC);
TAKE_OBJ_NOTNULL(vrg_priv, priv, VRG_PRIV_MAGIC);
if (vrg_priv->req->resp_len >= 0 &&
vrg_priv->range_off < vrg_priv->range_high) {
Req_Fail(vrg_priv->req, SC_RANGE_SHORT);
vrg_priv->req->vdc->retval = -1;
}
*priv = NULL; /* struct on ws, no need to free */
/* struct on ws, no need to free */
return (0);
}
......
......@@ -75,13 +75,15 @@ expression obj, priv, magic;
@@
- CAST_OBJ_NOTNULL(obj, *priv, magic);
- *priv = NULL;
+ TAKE_OBJ_NOTNULL(obj, priv, magic);
...
- *priv = NULL;
@@
expression obj, priv, magic;
@@
- CAST_OBJ_NOTNULL(obj, priv, magic);
- priv = NULL;
+ TAKE_OBJ_NOTNULL(obj, &priv, magic);
...
- priv = NULL;
......@@ -292,11 +292,10 @@ xyzzy_pedantic_fini(struct vdp_ctx *vdc, void **priv)
AN(priv);
if (*priv == NULL)
return (0);
CAST_OBJ_NOTNULL(vdps, *priv, VDP_STATE_MAGIC);
TAKE_OBJ_NOTNULL(vdps, priv, VDP_STATE_MAGIC);
assert(vdps->state == VDPS_INIT || vdps->state == VDPS_END);
vdps->state = VDPS_FINI;
*priv = NULL;
return (0);
}
......@@ -497,8 +496,7 @@ xyzzy_chksha256_fini(struct vdp_ctx *vdc, void **priv)
AN(priv);
if (*priv == NULL)
return (0);
CAST_OBJ_NOTNULL(vdps, *priv, VDP_CHKSHA256_MAGIC);
*priv = NULL;
TAKE_OBJ_NOTNULL(vdps, priv, VDP_CHKSHA256_MAGIC);
VSHA256_Final(digest, vdps->cx);
r = memcmp(digest, vdps->cfg->expected, sizeof digest);
......@@ -542,8 +540,7 @@ xyzzy_chkcrc32_fini(struct vdp_ctx *vdc, void **priv)
AN(priv);
if (*priv == NULL)
return (0);
CAST_OBJ_NOTNULL(vdps, *priv, VDP_CHKCRC32_MAGIC);
*priv = NULL;
TAKE_OBJ_NOTNULL(vdps, priv, VDP_CHKCRC32_MAGIC);
if (vdps->crc == vdps->cfg->expected)
return (0);
......
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