Commit 1691267f authored by Vladimír Čunát's avatar Vladimír Čunát

knot_pkt_begin: fix beginning the same section again

The .pos value might get wrong (though I see no usage ATM).

- It still returns KNOT_EOK in case of equality; that's due to usage
  in resolver and requirement to special-case KNOT_ANSWER anyway.
- I would personally assert(false) on all internal failures (e.g. EINVAL),
  as immediate abortion seems preferrable when in debug mode, but the
  code around typically doesn't do that, so I left it without assertions.
parent cfe64de6
......@@ -483,17 +483,17 @@ uint16_t knot_pkt_qclass(const knot_pkt_t *pkt)
int knot_pkt_begin(knot_pkt_t *pkt, knot_section_t section_id)
if (pkt == NULL) {
if (pkt == NULL || section_id < pkt->current) {
/* Cannot step to lower section. */
assert(section_id >= pkt->current);
pkt->current = section_id;
/* Remember watermark. */
/* Remember watermark but not on repeated calls. */
pkt->sections[section_id].pkt = pkt;
pkt->sections[section_id].pos = pkt->rrset_count;
if (section_id > pkt->current) {
pkt->sections[section_id].pos = pkt->rrset_count;
pkt->current = section_id;
return KNOT_EOK;
......@@ -212,7 +212,7 @@ uint16_t knot_pkt_qclass(const knot_pkt_t *pkt);
* \param pkt
* \param section_id
* \return KNOT_EOK
int knot_pkt_begin(knot_pkt_t *pkt, knot_section_t section_id);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment