From 1626010f3e7f8e00daeec49aac9bc940ace46b12 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 25 Oct 2016 23:32:05 -0400 Subject: sfrt_get_unit_ctx(): added error trace support. --- src/driver/sfrt_unit_ctx.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/driver/sfrt_unit_ctx.c') diff --git a/src/driver/sfrt_unit_ctx.c b/src/driver/sfrt_unit_ctx.c index a17d78d..0052cce 100644 --- a/src/driver/sfrt_unit_ctx.c +++ b/src/driver/sfrt_unit_ctx.c @@ -6,15 +6,16 @@ #include #include "sofort_driver_impl.h" +#include "sofort_errinfo_impl.h" -static int sfrt_free_unit_ctx_impl(struct sfrt_unit_ctx_impl * ctx, int status) +static int sfrt_free_unit_ctx_impl(struct sfrt_unit_ctx_impl * ctx, int ret) { if (ctx) { sfrt_unmap_input(&ctx->map); free(ctx); } - return status; + return ret; } int sfrt_get_unit_ctx( @@ -24,11 +25,19 @@ int sfrt_get_unit_ctx( { struct sfrt_unit_ctx_impl * ctx; - if (!dctx || !(ctx = calloc(1,sizeof(*ctx)))) - return -1; + if (!dctx) + return SFRT_CUSTOM_ERROR( + dctx,SFRT_ERR_NULL_CONTEXT); + + else if (!(ctx = calloc(1,sizeof(*ctx)))) + return SFRT_BUFFER_ERROR(dctx); + + sfrt_driver_set_ectx( + dctx,0,path); if (sfrt_map_input(dctx,-1,path,PROT_READ,&ctx->map)) - return sfrt_free_unit_ctx_impl(ctx,-1); + return sfrt_free_unit_ctx_impl(ctx, + SFRT_NESTED_ERROR(dctx)); memcpy(&ctx->cctx,dctx->cctx, sizeof(ctx->cctx)); -- cgit v1.2.3