]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib: fixed dead code and early dereference
authorMarek Vavruša <marek.vavrusa@nic.cz>
Sun, 19 Apr 2015 19:46:30 +0000 (21:46 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Sun, 19 Apr 2015 19:46:30 +0000 (21:46 +0200)
lib/generic/pack.h
modules/hints/hints.c

index 9a4e0939911a010d81010e370e8c27c564867142..bd3a8a774444b53016c11cf24a813e1beb1e442b 100644 (file)
@@ -115,12 +115,12 @@ static inline uint8_t *pack_obj_next(uint8_t *it)
   */
 static inline int pack_obj_push(pack_t *pack, const uint8_t *obj, pack_objlen_t len)
 {
-       uint8_t *endp = pack_tail(*pack);
        size_t packed_len = len + sizeof(len);
        if (pack == NULL || (pack->len + packed_len) > pack->cap) {
                return -1;
        }
 
+       uint8_t *endp = pack_tail(*pack);
        memcpy(endp, (char *)&len, sizeof(len));
        memcpy(endp + sizeof(len), obj, len);
        pack->len += packed_len;
index 8b8873bbce7ab9b00bac77132d261831bbbe8242..2fa3ef0da55ca0ea2926947417097525208a83da 100644 (file)
@@ -253,7 +253,7 @@ static char* hint_get(void *env, struct kr_module *module, const char *args)
        }
 
        char *result = NULL;
-       asprintf(&result, "{ \"result\": [ %s ] }", hint_buf ? hint_buf : "");
+       asprintf(&result, "{ \"result\": [ %s ] }", hint_buf);
        return result;
 }