From: Marek VavruĊĦa Date: Fri, 3 Jul 2015 22:01:12 +0000 (+0200) Subject: lib: cleanup X-Git-Tag: v1.0.0-beta1~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72922a43fcdb8c0d3a5bb2c29d78be52f61889c9;p=thirdparty%2Fknot-resolver.git lib: cleanup --- diff --git a/lib/layer/pktcache.c b/lib/layer/pktcache.c index b1453f1ff..4cac85a98 100644 --- a/lib/layer/pktcache.c +++ b/lib/layer/pktcache.c @@ -67,15 +67,14 @@ static int loot_cache_pkt(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_ /* Copy answer, keep the original message id */ if (entry->count <= pkt->max_size) { /* Keep original header and copy cached */ - uint8_t header[KNOT_WIRE_HEADER_SIZE]; - memcpy(header, pkt->wire, sizeof(header)); + uint16_t msgid = knot_wire_get_id(pkt->wire); /* Copy and reparse */ knot_pkt_clear(pkt); memcpy(pkt->wire, entry->data, entry->count); pkt->size = entry->count; knot_pkt_parse(pkt, 0); /* Restore header bits */ - knot_wire_set_id(pkt->wire, knot_wire_get_id(header)); + knot_wire_set_id(pkt->wire, msgid); } /* Adjust TTL in records. */ diff --git a/lib/utils.h b/lib/utils.h index e26fedd76..405be2c2f 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -36,7 +36,9 @@ extern void _cleanup_fclose(FILE **p); /** @internal Fast packet reset. */ #define KR_PKT_RECYCLE(pkt) do { \ - (pkt)->parsed = (pkt)->size = KNOT_WIRE_HEADER_SIZE; \ + (pkt)->current = KNOT_ANSWER; \ + (pkt)->rrset_count = 0; \ + (pkt)->size = KNOT_WIRE_HEADER_SIZE; \ knot_pkt_parse_question((pkt)); \ } while (0)