diff options
author | midipix <writeonce@midipix.org> | 2016-10-24 20:19:29 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-10 23:35:52 -0500 |
commit | 9b7081116d8da0807045911704449a65217211c3 (patch) | |
tree | 7f04f65672aa4cf24377e583ab66fb139c9467ff /src | |
parent | 0e3fd6a8154ca4121f9eb958903e9e9ef9a4eb99 (diff) | |
download | perk-9b7081116d8da0807045911704449a65217211c3.tar.bz2 perk-9b7081116d8da0807045911704449a65217211c3.tar.xz |
pe_get_unit_ctx(): added error trace support.
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/pe_unit_ctx.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/driver/pe_unit_ctx.c b/src/driver/pe_unit_ctx.c index 76ee376..2ea690e 100644 --- a/src/driver/pe_unit_ctx.c +++ b/src/driver/pe_unit_ctx.c @@ -12,8 +12,9 @@ #include <perk/perk.h> #include "perk_driver_impl.h" +#include "perk_errinfo_impl.h" -static int pe_free_unit_ctx_impl(struct pe_unit_ctx_impl * ctx, int status) +static int pe_free_unit_ctx_impl(struct pe_unit_ctx_impl * ctx, int ret) { if (ctx) { pe_free_image_meta(ctx->meta); @@ -21,7 +22,7 @@ static int pe_free_unit_ctx_impl(struct pe_unit_ctx_impl * ctx, int status) free(ctx); } - return status; + return ret; } int pe_get_unit_ctx( @@ -32,18 +33,23 @@ int pe_get_unit_ctx( struct pe_unit_ctx_impl * ctx; int prot; - if (!dctx || !(ctx = calloc(1,sizeof(*ctx)))) - return -1; + if (!dctx) + return PERK_CUSTOM_ERROR(dctx,0); + + else if (!(ctx = calloc(1,sizeof(*ctx)))) + return PERK_BUFFER_ERROR(dctx); prot = (dctx->cctx->actflags & PERK_ACTION_MAP_READWRITE) ? PROT_READ | PROT_WRITE : PROT_READ; if (pe_map_raw_image(dctx->cctx->ioctx->fdin,path,prot,&ctx->map)) - return pe_free_unit_ctx_impl(ctx,-1); + return pe_free_unit_ctx_impl(ctx, + PERK_SYSTEM_ERROR(dctx)); if (pe_get_image_meta(dctx,&ctx->map,&ctx->meta)) - return pe_free_unit_ctx_impl(ctx,-1); + return pe_free_unit_ctx_impl(ctx, + PERK_NESTED_ERROR(dctx)); memcpy(&ctx->cctx,dctx->cctx, sizeof(ctx->cctx)); |