Rename ERR macros -> FAIL

parent 0f4d0d8a
...@@ -41,17 +41,17 @@ ...@@ -41,17 +41,17 @@
#include "byte_order.h" #include "byte_order.h"
#define ERR(ctx, msg) \ #define FAIL(ctx, msg) \
VRT_fail((ctx), "vmod blobdigest error: " msg) VRT_fail((ctx), "vmod blobdigest error: " msg)
#define VERR(ctx, fmt, ...) \ #define VFAIL(ctx, fmt, ...) \
VRT_fail((ctx), "vmod blobdigest error: " fmt, __VA_ARGS__) VRT_fail((ctx), "vmod blobdigest error: " fmt, __VA_ARGS__)
#define VERRNOMEM(ctx, fmt, ...) \ #define VFAILNOMEM(ctx, fmt, ...) \
VERR((ctx), fmt ", out of space", __VA_ARGS__) VFAIL((ctx), fmt ", out of space", __VA_ARGS__)
#define ERRNOMEM(ctx, msg) \ #define FAILNOMEM(ctx, msg) \
ERR((ctx), msg ", out of space") FAIL((ctx), msg ", out of space")
#define INIT_FINI(ctx) (((ctx)->method & (VCL_MET_INIT | VCL_MET_FINI)) != 0) #define INIT_FINI(ctx) (((ctx)->method & (VCL_MET_INIT | VCL_MET_FINI)) != 0)
...@@ -268,7 +268,7 @@ ws_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp, ...@@ -268,7 +268,7 @@ ws_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp,
spc = WS_Alloc(ctx->ws, PRNDUP(digestsz) + sizeof *b); spc = WS_Alloc(ctx->ws, PRNDUP(digestsz) + sizeof *b);
if (spc == NULL) { if (spc == NULL) {
VERRNOMEM(ctx, "WS_Alloc in %s.%s()", context, caller); VFAILNOMEM(ctx, "WS_Alloc in %s.%s()", context, caller);
return (NULL); return (NULL);
} }
...@@ -292,7 +292,7 @@ heap_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp, ...@@ -292,7 +292,7 @@ heap_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp,
spc = malloc(PRNDUP(digestsz) + sizeof *b); spc = malloc(PRNDUP(digestsz) + sizeof *b);
if (spc == NULL) { if (spc == NULL) {
VERRNOMEM(ctx, "malloc in %s.%s()", context, caller); VFAILNOMEM(ctx, "malloc in %s.%s()", context, caller);
return (NULL); return (NULL);
} }
...@@ -329,7 +329,7 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -329,7 +329,7 @@ get_scope(const struct vrt_ctx * const restrict ctx,
break; break;
case TOP: { case TOP: {
if (ctx->req == NULL) { if (ctx->req == NULL) {
VERR(ctx, "%s.%s(): object has TOP scope - only " VFAIL(ctx, "%s.%s(): object has TOP scope - only "
"accessible in client VCL context", "accessible in client VCL context",
h->vcl_name, method); h->vcl_name, method);
return (NULL); return (NULL);
...@@ -347,7 +347,7 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -347,7 +347,7 @@ get_scope(const struct vrt_ctx * const restrict ctx,
} }
if (priv == NULL) { if (priv == NULL) {
ERR(ctx, "no priv - out of workspace?"); FAIL(ctx, "no priv - out of workspace?");
return (NULL); return (NULL);
} }
...@@ -361,7 +361,7 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -361,7 +361,7 @@ get_scope(const struct vrt_ctx * const restrict ctx,
else { else {
task = WS_Alloc(ws, sizeof(struct digest_task)); task = WS_Alloc(ws, sizeof(struct digest_task));
if (task == NULL) { if (task == NULL) {
VERRNOMEM(ctx, "allocating task data in %s.%s()", VFAILNOMEM(ctx, "allocating task data in %s.%s()",
h->vcl_name, method); h->vcl_name, method);
return (NULL); return (NULL);
} }
...@@ -431,7 +431,7 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b) ...@@ -431,7 +431,7 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
CHECK_OBJ_NOTNULL(h, VMOD_BLOBDIGEST_DIGEST_MAGIC); CHECK_OBJ_NOTNULL(h, VMOD_BLOBDIGEST_DIGEST_MAGIC);
if (h->result != NULL) { if (h->result != NULL) {
VERR(ctx, "already finalized in %s.update()", h->vcl_name); VFAIL(ctx, "already finalized in %s.update()", h->vcl_name);
return (0); return (0);
} }
...@@ -440,14 +440,14 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b) ...@@ -440,14 +440,14 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
return (0); return (0);
if (b == NULL) { if (b == NULL) {
VERR(ctx, "null BLOB passed to %s.update()", h->vcl_name); VFAIL(ctx, "null BLOB passed to %s.update()", h->vcl_name);
return (0); return (0);
} }
hctx = INIT_FINI(ctx) ? &h->ctx : &task->ctx; hctx = INIT_FINI(ctx) ? &h->ctx : &task->ctx;
if (task->result != NULL) { if (task->result != NULL) {
VERR(ctx, "already finalized in %s.update()", h->vcl_name); VFAIL(ctx, "already finalized in %s.update()", h->vcl_name);
return (0); return (0);
} }
if (b->len > 0 && b->blob != NULL) if (b->len > 0 && b->blob != NULL)
...@@ -563,7 +563,7 @@ vmod_hmac__init(VRT_CTX, struct vmod_blobdigest_hmac **hmacp, ...@@ -563,7 +563,7 @@ vmod_hmac__init(VRT_CTX, struct vmod_blobdigest_hmac **hmacp,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(vcl_name); AN(vcl_name);
if (key == NULL || key->blob == NULL) { if (key == NULL || key->blob == NULL) {
VERR(ctx, "key is NULL in %s constructor", vcl_name); VFAIL(ctx, "key is NULL in %s constructor", vcl_name);
return; return;
} }
AN(hmacp); AN(hmacp);
...@@ -585,7 +585,7 @@ vmod_hmac_hmac(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_BLOB msg) ...@@ -585,7 +585,7 @@ vmod_hmac_hmac(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_BLOB msg)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(h, VMOD_BLOBDIGEST_HMAC_MAGIC); CHECK_OBJ_NOTNULL(h, VMOD_BLOBDIGEST_HMAC_MAGIC);
if (msg == NULL || msg->blob == NULL) { if (msg == NULL || msg->blob == NULL) {
VERR(ctx, "msg is NULL in %s.hmac()", h->vcl_name); VFAIL(ctx, "msg is NULL in %s.hmac()", h->vcl_name);
return (NULL); return (NULL);
} }
...@@ -604,7 +604,7 @@ vmod_hmac_hmac_bench(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_INT n, ...@@ -604,7 +604,7 @@ vmod_hmac_hmac_bench(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_INT n,
uintptr_t snap; uintptr_t snap;
if (n <= 0) { if (n <= 0) {
ERR(ctx, "number of rounds must be greater than zero"); FAIL(ctx, "number of rounds must be greater than zero");
return (-1); return (-1);
} }
snap = WS_Snapshot(ctx->ws); snap = WS_Snapshot(ctx->ws);
...@@ -665,11 +665,11 @@ vmod_hmacf(VRT_CTX, VCL_ENUM hashs, VCL_BLOB key, VCL_BLOB msg) ...@@ -665,11 +665,11 @@ vmod_hmacf(VRT_CTX, VCL_ENUM hashs, VCL_BLOB key, VCL_BLOB msg)
hash_ctx inner_ctx, outer_ctx; hash_ctx inner_ctx, outer_ctx;
if (key == NULL || key->blob == NULL) { if (key == NULL || key->blob == NULL) {
ERR(ctx, "key is NULL in blobdigest.hmacf()"); FAIL(ctx, "key is NULL in blobdigest.hmacf()");
return (NULL); return (NULL);
} }
if (msg == NULL || msg->blob == NULL) { if (msg == NULL || msg->blob == NULL) {
ERR(ctx, "msg is NULL in blobdigest.hmacf()"); FAIL(ctx, "msg is NULL in blobdigest.hmacf()");
return (NULL); return (NULL);
} }
hmac_init(hash, key, &inner_ctx, &outer_ctx); hmac_init(hash, key, &inner_ctx, &outer_ctx);
......
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