Commit 0ba09bfd authored by Nils Goroll's avatar Nils Goroll

cstyle(9)

parent e6bb4125
...@@ -268,18 +268,18 @@ ws_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp, ...@@ -268,18 +268,18 @@ ws_alloc_digest(VRT_CTX, const size_t digestsz, void **digestp,
snap = WS_Snapshot(ctx->ws); snap = WS_Snapshot(ctx->ws);
if ((b = WS_Alloc(ctx->ws, sizeof *b)) == NULL) { if ((b = WS_Alloc(ctx->ws, sizeof *b)) == NULL) {
VERRNOMEM(ctx, "allocating blob in %s.%s()", context, caller); VERRNOMEM(ctx, "allocating blob in %s.%s()", context, caller);
return NULL; return (NULL);
} }
if ((b->blob = *digestp = WS_Alloc(ctx->ws, digestsz)) == NULL) { if ((b->blob = *digestp = WS_Alloc(ctx->ws, digestsz)) == NULL) {
WS_Reset(ctx->ws, snap); WS_Reset(ctx->ws, snap);
VERRNOMEM(ctx, "allocating hash result in %s.%s()", context, VERRNOMEM(ctx, "allocating hash result in %s.%s()", context,
caller); caller);
return NULL; return (NULL);
} }
b->type = BLOB_BLOBDIGEST_DIGEST_TYPE; b->type = BLOB_BLOBDIGEST_DIGEST_TYPE;
b->len = digestsz; b->len = digestsz;
return b; return (b);
} }
static VCL_BLOB static VCL_BLOB
...@@ -332,9 +332,9 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -332,9 +332,9 @@ get_scope(const struct vrt_ctx * const restrict ctx,
case TOP: { case TOP: {
if (ctx->req == NULL) { if (ctx->req == NULL) {
VERR(ctx, "%s.%s(): object has TOP scope - only " VERR(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);
} }
assert(ctx->req->topreq); assert(ctx->req->topreq);
...@@ -348,7 +348,7 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -348,7 +348,7 @@ get_scope(const struct vrt_ctx * const restrict ctx,
if (priv == NULL) { if (priv == NULL) {
ERR(ctx, "no priv - out of workspace?"); ERR(ctx, "no priv - out of workspace?");
return NULL; return (NULL);
} }
AN(priv); AN(priv);
...@@ -362,8 +362,8 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -362,8 +362,8 @@ get_scope(const struct vrt_ctx * const restrict ctx,
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()", VERRNOMEM(ctx, "allocating task data in %s.%s()",
h->vcl_name, method); h->vcl_name, method);
return NULL; return (NULL);
} }
task->magic = VMOD_BLOBDIGEST_DIGEST_TASK_MAGIC; task->magic = VMOD_BLOBDIGEST_DIGEST_TASK_MAGIC;
memcpy(&task->ctx, &h->ctx, sizeof(hash_ctx)); memcpy(&task->ctx, &h->ctx, sizeof(hash_ctx));
...@@ -372,7 +372,7 @@ get_scope(const struct vrt_ctx * const restrict ctx, ...@@ -372,7 +372,7 @@ get_scope(const struct vrt_ctx * const restrict ctx,
priv->len = sizeof(struct digest_task); priv->len = sizeof(struct digest_task);
priv->free = NULL; priv->free = NULL;
} }
return task; return (task);
} }
VCL_VOID VCL_VOID
...@@ -431,31 +431,31 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b) ...@@ -431,31 +431,31 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
if (h->result != NULL) { if (h->result != NULL) {
VERR(ctx, "already finalized in %s.update()", h->vcl_name); VERR(ctx, "already finalized in %s.update()", h->vcl_name);
return 0; return (0);
} }
task = get_scope(ctx, h, "update"); task = get_scope(ctx, h, "update");
if (task == NULL) if (task == NULL)
return 0; return (0);
if (b == NULL) { if (b == NULL) {
VERR(ctx, "null BLOB passed to %s.update()", h->vcl_name); VERR(ctx, "null BLOB passed to %s.update()", h->vcl_name);
return 0; return (0);
} }
if (INIT_FINI(ctx)) { if (INIT_FINI(ctx)) {
if (b->len > 0 && b->blob != NULL) if (b->len > 0 && b->blob != NULL)
update(h->hash, &h->ctx, b->blob, b->len); update(h->hash, &h->ctx, b->blob, b->len);
return 1; return (1);
} }
if (task->result != NULL) { if (task->result != NULL) {
VERR(ctx, "already finalized in %s.update()", h->vcl_name); VERR(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)
update(h->hash, &task->ctx, b->blob, b->len); update(h->hash, &task->ctx, b->blob, b->len);
return 1; return (1);
} }
VCL_BLOB VCL_BLOB
...@@ -540,7 +540,7 @@ hmac_final(VRT_CTX, enum algorithm hash, VCL_BLOB restrict msg, ...@@ -540,7 +540,7 @@ hmac_final(VRT_CTX, enum algorithm hash, VCL_BLOB restrict msg,
b = ws_alloc_digest(ctx, digestsz, &digest, context, caller); b = ws_alloc_digest(ctx, digestsz, &digest, context, caller);
if (b == NULL) if (b == NULL)
return NULL; return (NULL);
AN(digest); AN(digest);
...@@ -589,14 +589,14 @@ vmod_hmac_hmac(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_BLOB msg) ...@@ -589,14 +589,14 @@ vmod_hmac_hmac(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_BLOB msg)
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); VERR(ctx, "msg is NULL in %s.hmac()", h->vcl_name);
return NULL; return (NULL);
} }
memcpy(&inner_ctx, &h->inner_ctx, sizeof(hash_ctx)); memcpy(&inner_ctx, &h->inner_ctx, sizeof(hash_ctx));
memcpy(&outer_ctx, &h->outer_ctx, sizeof(hash_ctx)); memcpy(&outer_ctx, &h->outer_ctx, sizeof(hash_ctx));
return hmac_final(ctx, h->hash, msg, &inner_ctx, &outer_ctx, return (hmac_final(ctx, h->hash, msg, &inner_ctx, &outer_ctx,
h->vcl_name, "hmac"); h->vcl_name, "hmac"));
} }
VCL_DURATION VCL_DURATION
...@@ -647,13 +647,13 @@ vmod_hash(VRT_CTX, VCL_ENUM hashs, VCL_BLOB msg) ...@@ -647,13 +647,13 @@ vmod_hash(VRT_CTX, VCL_ENUM hashs, VCL_BLOB msg)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (msg == NULL) if (msg == NULL)
return NULL; return (NULL);
b = ws_alloc_digest(ctx, hashspec[hash].digestsz, &r, b = ws_alloc_digest(ctx, hashspec[hash].digestsz, &r,
"blobdigest", "hash"); "blobdigest", "hash");
if (b == NULL) if (b == NULL)
return NULL; return (NULL);
AN(r); AN(r);
digest(hash, hctx, msg, r); digest(hash, hctx, msg, r);
...@@ -669,21 +669,21 @@ vmod_hmacf(VRT_CTX, VCL_ENUM hashs, VCL_BLOB key, VCL_BLOB msg) ...@@ -669,21 +669,21 @@ vmod_hmacf(VRT_CTX, VCL_ENUM hashs, VCL_BLOB key, VCL_BLOB msg)
if (key == NULL || key->blob == NULL) { if (key == NULL || key->blob == NULL) {
ERR(ctx, "key is NULL in blobdigest.hmacf()"); ERR(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()"); ERR(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);
return hmac_final(ctx, hash, msg, &inner_ctx, &outer_ctx, "blobdigest", return (hmac_final(ctx, hash, msg, &inner_ctx, &outer_ctx, "blobdigest",
"hmacf"); "hmacf"));
} }
VCL_STRING VCL_STRING
vmod_version(VRT_CTX __attribute__((unused))) vmod_version(VRT_CTX __attribute__((unused)))
{ {
return VERSION; return (VERSION);
} }
/* vend.h is varinshd private */ /* vend.h is varinshd private */
......
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