summaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-25 23:32:05 -0400
committermidipix <writeonce@midipix.org>2016-10-25 23:32:05 -0400
commit1626010f3e7f8e00daeec49aac9bc940ace46b12 (patch)
tree127f41f3032b66990ab4cb259ced02478637c791 /src/driver
parent7a168e9613504900a0f371aff0c1628946b7a877 (diff)
downloadsofort-1626010f3e7f8e00daeec49aac9bc940ace46b12.tar.bz2
sofort-1626010f3e7f8e00daeec49aac9bc940ace46b12.tar.xz
sfrt_get_unit_ctx(): added error trace support.
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/sfrt_unit_ctx.c19
1 files changed, 14 insertions, 5 deletions
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 <sofort/sofort.h>
#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));