From 8b166a9becf45c5871b4dbc2395acca21d2ffa13 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sun, 3 Apr 2016 02:43:34 -0300 Subject: [PATCH] remove asprintf warnings --- modules/cachectl/cachectl.c | 6 ++++-- modules/hints/hints.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/cachectl/cachectl.c b/modules/cachectl/cachectl.c index f47bc4252..abc93d22a 100644 --- a/modules/cachectl/cachectl.c +++ b/modules/cachectl/cachectl.c @@ -192,9 +192,11 @@ static char* prune(void *env, struct kr_module *module, const char *args) char *result = NULL; ret = kr_cache_txn_commit(&txn); if (ret != 0) { - asprintf(&result, "{ \"pruned\": %d, \"error\": \"%s\" }", pruned, knot_strerror(ret)); + if (-1 == asprintf(&result, "{ \"pruned\": %d, \"error\": \"%s\" }", pruned, knot_strerror(ret))) + result = NULL; } else { - asprintf(&result, "{ \"pruned\": %d }", pruned); + if (-1 == asprintf(&result, "{ \"pruned\": %d }", pruned)) + result = NULL; } return result; diff --git a/modules/hints/hints.c b/modules/hints/hints.c index ff7eb922a..b68e5dec7 100644 --- a/modules/hints/hints.c +++ b/modules/hints/hints.c @@ -329,7 +329,8 @@ static char* hint_set(void *env, struct kr_module *module, const char *args) } char *result = NULL; - asprintf(&result, "{ \"result\": %s", ret == 0 ? "true" : "false"); + if (-1 == asprintf(&result, "{ \"result\": %s }", ret == 0 ? "true" : "false")) + result = NULL; return result; } -- 2.47.2