From: Libor Peltan Date: Tue, 12 Aug 2025 09:56:46 +0000 (+0200) Subject: kjournalprint: dont silently skip failed knot_rrset_txt_dump X-Git-Tag: v3.5.0~31^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=038c377460345c26fbdbf9980254d73607d36144;p=thirdparty%2Fknot-dns.git kjournalprint: dont silently skip failed knot_rrset_txt_dump --- diff --git a/src/knot/updates/changesets.c b/src/knot/updates/changesets.c index 5e24481a78..72334f88e2 100644 --- a/src/knot/updates/changesets.c +++ b/src/knot/updates/changesets.c @@ -592,10 +592,11 @@ int changeset_walk(const changeset_t *changeset, changeset_walk_callback callbac return KNOT_EOK; } -void changeset_print(const changeset_t *changeset, FILE *outfile, bool color) +int changeset_print(const changeset_t *changeset, FILE *outfile, bool color) { size_t buflen = 1024; char *buff = malloc(buflen); + int ret = KNOT_EOK; knot_dump_style_t style = KNOT_DUMP_STYLE_DEFAULT; style.now = knot_time(); @@ -605,20 +606,25 @@ void changeset_print(const changeset_t *changeset, FILE *outfile, bool color) fprintf(outfile, "%s;; Removed%s\n", style.color, COL_RST(color)); } if (changeset->soa_from != NULL && buff != NULL) { - (void)knot_rrset_txt_dump(changeset->soa_from, &buff, &buflen, &style); + ret = knot_rrset_txt_dump(changeset->soa_from, &buff, &buflen, &style); fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color)); } - (void)zone_dump_text(changeset->remove, NULL, outfile, false, style.color); + if (ret >= 0 && changeset->remove != NULL) { // Can be NULL if zone-in-journal + ret = zone_dump_text(changeset->remove, NULL, outfile, false, style.color); + } style.color = COL_GRN(color); if (changeset->soa_to != NULL || !zone_contents_is_empty(changeset->add)) { fprintf(outfile, "%s;; Added%s\n", style.color, COL_RST(color)); } - if (changeset->soa_to != NULL && buff != NULL) { - (void)knot_rrset_txt_dump(changeset->soa_to, &buff, &buflen, &style); + if (changeset->soa_to != NULL && buff != NULL && ret >= 0) { + ret = knot_rrset_txt_dump(changeset->soa_to, &buff, &buflen, &style); fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color)); } - (void)zone_dump_text(changeset->add, NULL, outfile, false, style.color); + if (ret >= 0) { + ret = zone_dump_text(changeset->add, NULL, outfile, false, style.color); + } free(buff); + return ret >= 0 ? KNOT_EOK : ret; } diff --git a/src/knot/updates/changesets.h b/src/knot/updates/changesets.h index 5c4187080e..534f61cf14 100644 --- a/src/knot/updates/changesets.h +++ b/src/knot/updates/changesets.h @@ -275,5 +275,7 @@ int changeset_walk(const changeset_t *changeset, changeset_walk_callback callbac * \param changeset Changeset. * \param outfile File to write into. * \param color Use unix tty color metacharacters. + * + * \return KNOT_E* */ -void changeset_print(const changeset_t *changeset, FILE *outfile, bool color); +int changeset_print(const changeset_t *changeset, FILE *outfile, bool color); diff --git a/src/knot/zone/zone-dump.c b/src/knot/zone/zone-dump.c index 8724701c2b..7793922e0b 100644 --- a/src/knot/zone/zone-dump.c +++ b/src/knot/zone/zone-dump.c @@ -80,8 +80,7 @@ static int node_dump_text(zone_node_t *node, void *data) // Zone apex rrsets. if (node->owner == params->origin && !params->dump_rrsig && !params->dump_nsec) { - apex_node_dump_text(node, params); - return KNOT_EOK; + return apex_node_dump_text(node, params); } // Dump non-apex rrsets. diff --git a/src/utils/kjournalprint/main.c b/src/utils/kjournalprint/main.c index 57d9fb3ca7..6d536c1412 100644 --- a/src/utils/kjournalprint/main.c +++ b/src/utils/kjournalprint/main.c @@ -71,7 +71,7 @@ typedef struct { uint64_t merged_ts; } print_params_t; -static void print_changeset(const changeset_t *chs, uint64_t timestamp, print_params_t *params) +static int print_changeset(const changeset_t *chs, uint64_t timestamp, print_params_t *params) { char time_buf[64] = { 0 }; (void)knot_time_print(TIME_PRINT_UNIX, timestamp, time_buf, sizeof(time_buf)); @@ -93,7 +93,7 @@ static void print_changeset(const changeset_t *chs, uint64_t timestamp, print_pa time_buf, COL_RST(params->color)); } - changeset_print(chs, stdout, params->color); + return changeset_print(chs, stdout, params->color); } typedef struct { @@ -198,6 +198,7 @@ static int merge_changeset_cb(bool special, const changeset_t *ch, uint64_t time static int print_changeset_cb(bool special, const changeset_t *ch, uint64_t timestamp, void *ctx) { print_params_t *params = ctx; + int ret = KNOT_EOK; if (ch != NULL && params->counter++ >= params->limit) { if (params->merge) { return merge_changeset_cb(special, ch, timestamp, ctx); @@ -205,13 +206,13 @@ static int print_changeset_cb(bool special, const changeset_t *ch, uint64_t time print_changeset_debugmode(ch, timestamp); params->changes++; } else { - print_changeset(ch, timestamp, params); + ret = print_changeset(ch, timestamp, params); } if (special && params->debug) { printf("---------------------------------------------\n"); } } - return KNOT_EOK; + return ret; } int print_journal(char *path, knot_dname_t *name, print_params_t *params)