X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb%2Fkeydb_pg.c;h=85c16ccbdcf39d10c2e3aa0584e4da7c67517d49;hb=f67f09be8979050e73855b6551da83ca48dde950;hp=1b58c1a5f27c71f1788c1e7783e70aa60df7b77a;hpb=67f26da9c26e544b723ac73ac67383519c873e30;p=onak.git diff --git a/keydb/keydb_pg.c b/keydb/keydb_pg.c index 1b58c1a..85c16cc 100644 --- a/keydb/keydb_pg.c +++ b/keydb/keydb_pg.c @@ -28,6 +28,7 @@ #include #include +#include "build-config.h" #include "hash.h" #include "keydb.h" #include "keyid.h" @@ -46,21 +47,28 @@ struct pg_fc_ctx { /** * keydb_fetchchar - Fetches a char from a file. */ -static int keydb_fetchchar(void *_ctx, size_t count, void *c) +static size_t keydb_fetchchar(void *_ctx, size_t count, void *c) { + int ret; + struct pg_fc_ctx *ctx = (struct pg_fc_ctx *) _ctx; - return (!lo_read(ctx->dbconn, ctx->fd, (char *) c, count)); + ret = lo_read(ctx->dbconn, ctx->fd, (char *) c, count); + + return (ret > 0) ? ret : 0; } /** * keydb_putchar - Puts a char to a file. */ -static int keydb_putchar(void *_ctx, size_t count, void *c) +static size_t keydb_putchar(void *_ctx, size_t count, void *c) { struct pg_fc_ctx *ctx = (struct pg_fc_ctx *) _ctx; + int ret; + + ret = lo_write(ctx->dbconn, ctx->fd, (char *) c, count); - return !(lo_write(ctx->dbconn, ctx->fd, (char *) c, count)); + return (ret > 0) ? ret : 0; } /** @@ -671,7 +679,8 @@ static void pg_cleanupdb(struct onak_dbctx *dbctx) * this file are called in order to allow the DB to be initialized ready * for access. */ -struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg, bool readonly) +struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg, + __unused bool readonly) { struct onak_dbctx *dbctx; PGconn *dbconn;