From: Daniel Kahn Gillmor Date: Sun, 3 Apr 2016 05:43:34 +0000 (-0300) Subject: remove asprintf warnings X-Git-Tag: v1.0.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b166a9becf45c5871b4dbc2395acca21d2ffa13;p=thirdparty%2Fknot-resolver.git remove asprintf warnings --- 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; }