]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
remove asprintf warnings
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 3 Apr 2016 05:43:34 +0000 (02:43 -0300)
committerMarek Vavrusa <marek@vavrusa.com>
Thu, 14 Apr 2016 05:36:42 +0000 (22:36 -0700)
modules/cachectl/cachectl.c
modules/hints/hints.c

index f47bc42520b7faa9a3fb9c1fecf5800cbd2336d7..abc93d22a7dfb5131f552936d67179dff07833f9 100644 (file)
@@ -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;
index ff7eb922a190d634905c26973c66917d50ce3612..b68e5dec778b3cdfc9e04f673e691d668ba5e97a 100644 (file)
@@ -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;
 }