Commit 4e8a19a4 authored by Geoff Simmons's avatar Geoff Simmons

Simplify the decrypt_init() params.

parent e2f0680a
...@@ -48,15 +48,16 @@ ...@@ -48,15 +48,16 @@
#define HDR_LEN(hdr) ((hdr)->next_in - (hdr)->hdr) #define HDR_LEN(hdr) ((hdr)->next_in - (hdr)->hdr)
static enum vfp_status static enum vfp_status
decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg, decrypt_init(struct vfp_ctx *ctx, struct ece *ece, struct vfp_entry *ent)
const char *vfp_name)
{ {
struct vfp_settings *settings; struct vfp_settings *settings;
const struct vfp_cfg *cfg;
struct ece_hdrbuf *hdr; struct ece_hdrbuf *hdr;
enum vfp_status vp; enum vfp_status vp;
size_t len; size_t len;
uint32_t rs; uint32_t rs;
uint8_t idlen; uint8_t idlen;
const char *name;
CHECK_OBJ_NOTNULL(ctx, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(ctx->wrk, WORKER_MAGIC);
...@@ -64,9 +65,14 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg, ...@@ -64,9 +65,14 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg,
CHECK_OBJ_NOTNULL(ece, ECE_MAGIC); CHECK_OBJ_NOTNULL(ece, ECE_MAGIC);
CHECK_OBJ_NOTNULL(ece->crypto, ECE_CRYPTO_MAGIC); CHECK_OBJ_NOTNULL(ece->crypto, ECE_CRYPTO_MAGIC);
CHECK_OBJ_NOTNULL(ece->hdr, ECE_HDRBUF_MAGIC); CHECK_OBJ_NOTNULL(ece->hdr, ECE_HDRBUF_MAGIC);
CHECK_OBJ_NOTNULL(cfg, VFP_CFG_MAGIC); CHECK_OBJ_NOTNULL(ent, VFP_ENTRY_MAGIC);
AN(ent->vfp);
CAST_OBJ_NOTNULL(cfg, ent->vfp->priv1, VFP_CFG_MAGIC);
CHECK_OBJ_NOTNULL(cfg->settings, VFP_SETTINGS_MAGIC); CHECK_OBJ_NOTNULL(cfg->settings, VFP_SETTINGS_MAGIC);
AN(vfp_name); AN(ent->vfp->name);
settings = cfg->settings;
name = ent->vfp->name;
AZ(ece->rs); AZ(ece->rs);
AZ(ece->chunksz); AZ(ece->chunksz);
AZ(ece->buf); AZ(ece->buf);
...@@ -74,7 +80,6 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg, ...@@ -74,7 +80,6 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg,
AN(hdr->hdr); AN(hdr->hdr);
AN(hdr->next_in); AN(hdr->next_in);
AN(hdr->avail_in); AN(hdr->avail_in);
settings = cfg->settings;
if (HDR_LEN(hdr) < HDR_PFX_LEN) { if (HDR_LEN(hdr) < HDR_PFX_LEN) {
len = HDR_PFX_LEN - HDR_LEN(hdr); len = HDR_PFX_LEN - HDR_LEN(hdr);
...@@ -149,10 +154,10 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg, ...@@ -149,10 +154,10 @@ decrypt_init(struct vfp_ctx *ctx, struct ece *ece, const struct vfp_cfg *cfg,
ece->stream->rec_next = ece->stream->rec_buf; ece->stream->rec_next = ece->stream->rec_buf;
AZ(ece->stream->rec_avail); AZ(ece->stream->rec_avail);
VSLb(ctx->wrk->vsl, SLT_Debug, "%s: id \"%.*s\"", vfp_name, idlen, VSLb(ctx->wrk->vsl, SLT_Debug, "%s: id \"%.*s\"", name, idlen,
hdr->hdr + HDR_PFX_LEN); hdr->hdr + HDR_PFX_LEN);
VSLb(ctx->wrk->vsl, SLT_Debug, "%s: record size %u", vfp_name, ece->rs); VSLb(ctx->wrk->vsl, SLT_Debug, "%s: record size %u", name, ece->rs);
VSLb(ctx->wrk->vsl, SLT_Debug, "%s: chunk size %zu", vfp_name, VSLb(ctx->wrk->vsl, SLT_Debug, "%s: chunk size %zu", name,
ece->chunksz); ece->chunksz);
return (VFP_END); return (VFP_END);
...@@ -282,7 +287,6 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -282,7 +287,6 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
{ {
struct ece *ece; struct ece *ece;
struct ece_stream *stream; struct ece_stream *stream;
const struct vfp_cfg *cfg;
unsigned char *p = ptr; unsigned char *p = ptr;
enum vfp_status vp = VFP_OK; enum vfp_status vp = VFP_OK;
...@@ -296,11 +300,7 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr, ...@@ -296,11 +300,7 @@ vfp_decrypt_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
stream = ece->stream; stream = ece->stream;
if (ece->rs == 0) { if (ece->rs == 0) {
CHECK_OBJ_NOTNULL(ent, VFP_ENTRY_MAGIC); vp = decrypt_init(ctx, ece, ent);
AN(ent->vfp);
AN(ent->vfp->name);
CAST_OBJ_NOTNULL(cfg, ent->vfp->priv1, VFP_CFG_MAGIC);
vp = decrypt_init(ctx, ece, cfg, ent->vfp->name);
if (vp == VFP_ERROR) if (vp == VFP_ERROR)
return (vp); return (vp);
if (vp == VFP_NULL) { if (vp == VFP_NULL) {
......
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