]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
properly check fprintf() and fclose() return value
authorDavid Vašek <david.vasek@nic.cz>
Thu, 25 Sep 2025 09:04:52 +0000 (11:04 +0200)
committerDavid Vašek <david.vasek@nic.cz>
Tue, 7 Oct 2025 14:32:11 +0000 (16:32 +0200)
JSON functions, tests, and debug functions, where it isn't vital, remain without checking.
Checking and reporting for log and stats files will be solved separately.

18 files changed:
src/contrib/files.c
src/contrib/json.c
src/knot/common/log.c
src/knot/common/process.c
src/knot/conf/base.c
src/knot/conf/confdb.c
src/knot/updates/changesets.c
src/knot/updates/zone-update.c
src/knot/zone/backup_dir.c
src/knot/zone/zone-dump.c
src/knot/zone/zonefile.c
src/libknot/tsig.c
src/libknot/xdp/xdp.c
src/utils/common/resolv.c
src/utils/knotd/main.c
src/utils/knsupdate/knsupdate_exec.c
src/utils/kxdpgun/load_queries.c
src/utils/kzonecheck/zone_check.c

index 89a818676241f8865aa7ebeb4a864a1edfb7d870..4d58694552beed49cde7049869f4f119a69aad48 100644 (file)
@@ -248,12 +248,12 @@ int copy_file(const char *dest, const char *src)
 
 done:
        free(tmp_name);
-       if (file != NULL) {
-               fclose(file);
+       if (file != NULL && fclose(file) == -1 && ret == KNOT_EOK) {
+               ret = knot_map_errno();
        }
        free(buf);
        if (from != NULL) {
-               fclose(from);
+               (void)fclose(from);
        }
        return ret;
 }
index aba6d59fbc217e5aa8aaf7837dc7a35266962de6..3a4f1cb66f13f67ba4c76184b6cf389e451ba958 100644 (file)
@@ -74,7 +74,7 @@ static void wrap(jsonw_t *w)
        fputc('\n', w->out);
        int level = MAX_DEPTH - w->top;
        for (int i = 0; i < level; i++) {
-               fprintf(w->out, "%s", w->indent);
+               (void)fprintf(w->out, "%s", w->indent);
        }
 }
 
@@ -95,7 +95,7 @@ static void escaped_print(jsonw_t *w, const char *str, size_t maxlen, bool quote
                if (c == '\\' || c == '\"') {
                        fputc('\\', w->out);
                } else if (c == '\0') {
-                       fprintf(w->out, "\\u0000");
+                       (void)fprintf(w->out, "\\u0000");
                        continue;
                }
                fputc(c, w->out);
@@ -116,7 +116,7 @@ static void align_key(jsonw_t *w, const char *key)
 
        if (key && key[0]) {
                escaped_print(w, key, SIZE_MAX, true);
-               fprintf(w->out, ": ");
+               (void)fprintf(w->out, ": ");
        }
 }
 
@@ -153,7 +153,7 @@ void jsonw_null(jsonw_t *w, const char *key)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "null");
+       (void)fprintf(w->out, "null");
 }
 
 void jsonw_object(jsonw_t *w, const char *key)
@@ -161,7 +161,7 @@ void jsonw_object(jsonw_t *w, const char *key)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "{");
+       (void)fprintf(w->out, "{");
        start_block(w, BLOCK_OBJECT);
 }
 
@@ -170,7 +170,7 @@ void jsonw_list(jsonw_t *w, const char *key)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "[");
+       (void)fprintf(w->out, "[");
        start_block(w, BLOCK_LIST);
 }
 
@@ -195,7 +195,7 @@ void jsonw_ulong(jsonw_t *w, const char *key, unsigned long value)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "%lu", value);
+       (void)fprintf(w->out, "%lu", value);
 }
 
 void jsonw_int(jsonw_t *w, const char *key, int value)
@@ -203,7 +203,7 @@ void jsonw_int(jsonw_t *w, const char *key, int value)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "%d", value);
+       (void)fprintf(w->out, "%d", value);
 }
 
 void jsonw_double(jsonw_t *w, const char *key, double value)
@@ -211,7 +211,7 @@ void jsonw_double(jsonw_t *w, const char *key, double value)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "%.4f", value);
+       (void)fprintf(w->out, "%.4f", value);
 }
 
 void jsonw_bool(jsonw_t *w, const char *key, bool value)
@@ -219,7 +219,7 @@ void jsonw_bool(jsonw_t *w, const char *key, bool value)
        assert(w);
 
        align_key(w, key);
-       fprintf(w->out, "%s", value ? "true" : "false");
+       (void)fprintf(w->out, "%s", value ? "true" : "false");
 }
 
 void jsonw_hex(jsonw_t *w, const char *key, const uint8_t *data, size_t len)
@@ -247,10 +247,10 @@ void jsonw_end(jsonw_t *w)
 
        switch (top->type) {
        case BLOCK_OBJECT:
-               fprintf(w->out, "}");
+               (void)fprintf(w->out, "}");
                break;
        case BLOCK_LIST:
-               fprintf(w->out, "]");
+               (void)fprintf(w->out, "]");
                break;
        }
 }
index 4795ded605d41f55f804f2e2c50aa01cabdfa970..cfdcb7ca3af3e43530e57901845f70837d648297 100644 (file)
@@ -172,7 +172,7 @@ void log_init(void)
        // Publish base log sink.
        log_t *log = sink_setup(0);
        if (log == NULL) {
-               fprintf(stderr, "Failed to setup logging\n");
+               (void)fprintf(stderr, "Failed to setup logging\n");
                return;
        }
 
@@ -456,7 +456,7 @@ void log_reconfigure(conf_t *conf)
        // Initialize logsystem.
        log_t *log = sink_setup(files);
        if (log == NULL) {
-               fprintf(stderr, "Failed to setup logging\n");
+               (void)fprintf(stderr, "Failed to setup logging\n");
                return;
        }
 
index f33f3b3d226c8c02dbe41d34deda12a9692a9f89..cda00797c06abe8cd4b5a1844e5e83b2e1c8f772 100644 (file)
@@ -47,7 +47,7 @@ static pid_t pid_read(const char *filename)
 
        /* Read the content of the file. */
        len = fread(buf, 1, sizeof(buf) - 1, fp);
-       fclose(fp);
+       (void)fclose(fp);
        if (len < 1) {
                return 0;
        }
@@ -84,7 +84,9 @@ static int pid_write(const char *filename, pid_t pid)
                if (write(fd, buf, len) != len) {
                        ret = knot_map_errno();
                }
-               close(fd);
+               if (close(fd) == -1 && ret == KNOT_EOK) {
+                       ret = knot_map_errno();
+               }
        } else {
                ret = knot_map_errno();
        }
index 3a64b2b82fb6373f98a9b563e80f52cba22ea22e..b3f0fe0b76a755f639ebb38c526f4bf9ed31e9dd 100644 (file)
@@ -868,9 +868,9 @@ static int export_group_name(
                return ret;
        }
 
-       fprintf(fp, "%s", out);
+       ret = (fprintf(fp, "%s", out) < 0) ? knot_map_errno() : KNOT_EOK;
 
-       return KNOT_EOK;
+       return ret;
 }
 
 static int export_group(
@@ -902,7 +902,9 @@ static int export_group(
                        if (ret != KNOT_EOK) {
                                return ret;
                        }
-                       fprintf(fp, "%s", out);
+                       if (fprintf(fp, "%s", out) < 0) {
+                               return knot_map_errno();
+                       }
                        continue;
                }
 
@@ -934,7 +936,9 @@ static int export_group(
                        if (ret != KNOT_EOK) {
                                return ret;
                        }
-                       fprintf(fp, "%s", out);
+                       if (fprintf(fp, "%s", out) < 0) {
+                               return knot_map_errno();
+                       }
 
                        if (values > 1) {
                                conf_val_next(&bin);
@@ -942,8 +946,8 @@ static int export_group(
                }
        }
 
-       if (*exported) {
-               fprintf(fp, "\n");
+       if (*exported && (fprintf(fp, "\n") < 0)) {
+               return knot_map_errno();
        }
 
        return KNOT_EOK;
@@ -1030,13 +1034,17 @@ int conf_export(
                return knot_map_errno();
        }
 
-       fprintf(fp, "# Configuration export (Knot DNS %s)\n\n", PACKAGE_VERSION);
+       int ret;
+
+       if (fprintf(fp, "# Configuration export (Knot DNS %s)\n\n",
+                   PACKAGE_VERSION) < 0) {
+               ret = knot_map_errno();
+               goto export_error;
+       }
 
        const char *mod_prefix = KNOTD_MOD_NAME_PREFIX;
        const size_t mod_prefix_len = strlen(mod_prefix);
 
-       int ret;
-
        // Iterate over the schema.
        for (yp_item_t *item = conf->schema; item->name != NULL; item++) {
                // Don't export module sections again.
@@ -1069,8 +1077,8 @@ int conf_export(
 
        ret = KNOT_EOK;
 export_error:
-       if (file_name != NULL) {
-               fclose(fp);
+       if (file_name != NULL && fclose(fp) == -1 && ret == KNOT_EOK) {
+               ret = knot_map_errno();
        }
        free(buff);
 
@@ -1297,8 +1305,8 @@ int conf_export_schema(
        jsonw_end(w);
        jsonw_free(&w);
 
-       if (file_name != NULL) {
-               fclose(fp);
+       if (file_name != NULL && fclose(fp) == -1 && ret == KNOT_EOK) {
+               ret = knot_map_errno();
        }
 
        return ret;
index 4177e3e498114b25aa83d3678bde3ed4ede67265..b079f7d8ba63947fd44f2b46ffdb61026834f0ef 100644 (file)
@@ -901,29 +901,29 @@ int conf_db_raw_dump(
                uint8_t *k = (uint8_t *)key.data;
                uint8_t *d = (uint8_t *)data.data;
                if (k[1] == KEY1_ITEMS) {
-                       fprintf(fp, "[%i][%i]%.*s", k[0], k[1],
-                               (int)key.len - 2, k + 2);
-                       fprintf(fp, ": %u\n", d[0]);
+                       (void)fprintf(fp, "[%i][%i]%.*s", k[0], k[1],
+                                     (int)key.len - 2, k + 2);
+                       (void)fprintf(fp, ": %u\n", d[0]);
                } else if (k[1] == KEY1_ID) {
-                       fprintf(fp, "[%i][%i](%zu){", k[0], k[1], key.len - 2);
+                       (void)fprintf(fp, "[%i][%i](%zu){", k[0], k[1], key.len - 2);
                        for (size_t i = 2; i < key.len; i++) {
-                               fprintf(fp, "%02x", (uint8_t)k[i]);
+                               (void)fprintf(fp, "%02x", (uint8_t)k[i]);
                        }
-                       fprintf(fp, "}\n");
+                       (void)fprintf(fp, "}\n");
                } else {
-                       fprintf(fp, "[%i][%i]", k[0], k[1]);
+                       (void)fprintf(fp, "[%i][%i]", k[0], k[1]);
                        if (key.len > 2) {
-                               fprintf(fp, "(%zu){", key.len - 2);
+                               (void)fprintf(fp, "(%zu){", key.len - 2);
                                for (size_t i = 2; i < key.len; i++) {
-                                       fprintf(fp, "%02x", (uint8_t)k[i]);
+                                       (void)fprintf(fp, "%02x", (uint8_t)k[i]);
                                }
-                               fprintf(fp, "}");
+                               (void)fprintf(fp, "}");
                        }
-                       fprintf(fp, ": (%zu)<", data.len);
+                       (void)fprintf(fp, ": (%zu)<", data.len);
                        for (size_t i = 0; i < data.len; i++) {
-                               fprintf(fp, "%02x", (uint8_t)d[i]);
+                               (void)fprintf(fp, "%02x", (uint8_t)d[i]);
                        }
-                       fprintf(fp, ">\n");
+                       (void)fprintf(fp, ">\n");
                }
 
                it = conf->api->iter_next(it);
@@ -931,9 +931,9 @@ int conf_db_raw_dump(
        conf->api->iter_finish(it);
 
        if (file_name != NULL) {
-               fclose(fp);
+               (void)fclose(fp);
        } else {
-               fflush(fp);
+               (void)fflush(fp);
        }
 
        return ret;
index 72334f88e2a6670e27ac55907e3d774b8f0876fe..b1e05953035243551616f530a2217d8463d9a6d6 100644 (file)
@@ -603,11 +603,15 @@ int changeset_print(const changeset_t *changeset, FILE *outfile, bool color)
 
        style.color = COL_RED(color);
        if (changeset->soa_from != NULL || !zone_contents_is_empty(changeset->remove)) {
-               fprintf(outfile, "%s;; Removed%s\n", style.color, COL_RST(color));
+               if (fprintf(outfile, "%s;; Removed%s\n", style.color, COL_RST(color)) < 0) {
+                       goto failed_outfile;
+               }
        }
        if (changeset->soa_from != NULL && buff != NULL) {
                ret = knot_rrset_txt_dump(changeset->soa_from, &buff, &buflen, &style);
-               fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color));
+               if (fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color)) < 0) {
+                       goto failed_outfile;
+               }
        }
        if (ret >= 0 && changeset->remove != NULL) { // Can be NULL if zone-in-journal
                ret = zone_dump_text(changeset->remove, NULL, outfile, false, style.color);
@@ -615,11 +619,15 @@ int changeset_print(const changeset_t *changeset, FILE *outfile, bool 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 (fprintf(outfile, "%s;; Added%s\n", style.color, COL_RST(color)) < 0) {
+                       goto failed_outfile;
+               }
        }
        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));
+               if (fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color)) < 0) {
+                       goto failed_outfile;
+               }
        }
        if (ret >= 0) {
                ret = zone_dump_text(changeset->add, NULL, outfile, false, style.color);
@@ -627,4 +635,8 @@ int changeset_print(const changeset_t *changeset, FILE *outfile, bool color)
 
        free(buff);
        return ret >= 0 ? KNOT_EOK : ret;
+
+failed_outfile:
+       free(buff);
+       return knot_map_errno();
 }
index 2f9d7778b7ac6bff1d614d0f32ec1de551326cf7..82574d197bd0218e237febbfa2337601cd9b9ea8 100644 (file)
@@ -1019,15 +1019,21 @@ static int dump_changeset_part(zone_update_t *up, bool additions,
        ctx.buflen = 1024;
        ctx.buf = malloc(ctx.buflen);
        if (ctx.buf == NULL) {
-               fclose(ctx.f);
+               (void)fclose(ctx.f);
                return KNOT_ENOMEM;
        }
        ctx.style = KNOT_DUMP_STYLE_DEFAULT;
        ctx.style.now = knot_time();
 
-       (void)fprintf(ctx.f, ";; %s records\n", additions ? "Added" : "Removed");
-       int ret = zone_update_foreach(up, additions, dump_rrset, &ctx);
-       fclose(ctx.f);
+       int ret;
+       if (fprintf(ctx.f, ";; %s records\n", additions ? "Added" : "Removed") > 0) {
+               ret = zone_update_foreach(up, additions, dump_rrset, &ctx);
+       } else {
+               ret = knot_map_errno();
+       }
+       if (fclose(ctx.f) == -1 && ret == KNOT_EOK) {
+               ret = knot_map_errno();
+       }
        free(ctx.buf);
        return ret;
 }
index 19007c0e6437444473bc5eb47a095dbb63bf8474..75512cc39c12d929960a38e2f75ed6eab5677a47 100644 (file)
@@ -151,7 +151,9 @@ static int make_label_file(zone_backup_ctx_t *ctx)
 
        ret = (ret < 0) ? knot_map_errno() : KNOT_EOK;
 
-       fclose(file);
+       if (fclose(file) == -1 && ret == KNOT_EOK) {
+               ret = knot_map_errno();
+       }
        return ret;
 }
 
@@ -236,7 +238,7 @@ static int get_backup_format(zone_backup_ctx_t *ctx)
 
 done:
        free(line);
-       fclose(file);
+       (void)fclose(file);
        return ret;
 }
 
index 7793922e0b101296a8296ff2f272fbe0472ef3d5..bca23cccd9742a27478a979dd9fbc9dc54c4775f 100644 (file)
@@ -39,7 +39,9 @@ static int apex_node_dump_text(zone_node_t *node, dump_params_t *params)
                        return ret;
                }
                params->rr_count += soa.rrs.count;
-               fprintf(params->file, "%s", params->buf);
+               if (fprintf(params->file, "%s", params->buf) < 0) {
+                       return knot_map_errno();
+               }
                params->buf[0] = '\0';
        }
 
@@ -66,7 +68,9 @@ static int apex_node_dump_text(zone_node_t *node, dump_params_t *params)
                        return ret;
                }
                params->rr_count +=  rrset.rrs.count;
-               fprintf(params->file, "%s", params->buf);
+               if (fprintf(params->file, "%s", params->buf) < 0) {
+                       return knot_map_errno();
+               }
                params->buf[0] = '\0';
        }
 
@@ -114,7 +118,9 @@ static int node_dump_text(zone_node_t *node, void *data)
 
                // Dump block comment if available.
                if (params->first_comment != NULL) {
-                       fprintf(params->file, "%s", params->first_comment);
+                       if (fprintf(params->file, "%s", params->first_comment) < 0) {
+                               return knot_map_errno();
+                       }
                        params->first_comment = NULL;
                }
 
@@ -124,7 +130,9 @@ static int node_dump_text(zone_node_t *node, void *data)
                        return ret;
                }
                params->rr_count += rrset.rrs.count;
-               fprintf(params->file, "%s", params->buf);
+               if (fprintf(params->file, "%s", params->buf) < 0) {
+                       return knot_map_errno();
+               }
                params->buf[0] = '\0';
        }
 
@@ -148,7 +156,9 @@ int zone_dump_text(zone_contents_t *zone, zone_skip_t *skip, FILE *file, bool co
        }
 
        if (comments) {
-               fprintf(file, ";; Zone dump (Knot DNS %s)\n", PACKAGE_VERSION);
+               if (fprintf(file, ";; Zone dump (Knot DNS %s)\n", PACKAGE_VERSION) < 0) {
+                       return knot_map_errno();
+               }
        }
 
        // Set structure with parameters.
@@ -222,12 +232,14 @@ int zone_dump_text(zone_contents_t *zone, zone_skip_t *skip, FILE *file, bool co
                strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S %Z", &tm);
 
                // Dump trailing statistics.
-               fprintf(file, ";; Written %"PRIu64" records\n"
-                             ";; Time %s\n",
-                       params.rr_count, date);
+               if (fprintf(file, ";; Written %"PRIu64" records\n"
+                                 ";; Time %s\n",
+                           params.rr_count, date) < 0) {
+                       ret = knot_map_errno();
+               }
        }
 
        free(params.buf); // params.buf may be != buf because of knot_rrset_txt_dump_dynamic()
 
-       return KNOT_EOK;
+       return ret;
 }
index 65f3b09f657bb6b65981d6e80cfffacc6521a847..ed34e115ef060c55cbee46c03a4d32832bb07d3b 100644 (file)
@@ -314,16 +314,15 @@ int zonefile_write(const char *path, zone_contents_t *zone, zone_skip_t *skip)
        }
 
        ret = zone_dump_text(zone, skip, file, true, NULL);
-       fclose(file);
        if (ret != KNOT_EOK) {
+               (void)fclose(file);
                unlink(tmp_name);
                free(tmp_name);
                return ret;
        }
 
-       /* Swap temporary zonefile and new zonefile. */
-       ret = rename(tmp_name, path);
-       if (ret != 0) {
+       /* Close, then swap temporary zonefile and new zonefile. */
+       if (fclose(file) == -1 || rename(tmp_name, path) == -1) {
                ret = knot_map_errno();
                unlink(tmp_name);
                free(tmp_name);
index cb05b34663c5592a9fc8796fbbf4a799c4ebb776..660db1760fdb5f0bc8c343eebfcfa8ab7feda918 100644 (file)
@@ -137,7 +137,7 @@ int knot_tsig_key_init_file(knot_tsig_key_t *key, const char *filename)
        size_t line_size = 0;
        ssize_t read = knot_getline(&line, &line_size, file);
 
-       fclose(file);
+       (void)fclose(file);
 
        if (read == -1) {
                return KNOT_EMALF;
index 943d9f2f3928c42fd0a3faa6225a06e8394a91d9..214675a8dd4811ec79a14f914e499933edcc33f4 100644 (file)
@@ -579,23 +579,23 @@ void knot_xdp_socket_info(const knot_xdp_socket_t *socket, FILE *file)
        }
 
        #define RING_PRINFO(name, ring) \
-               fprintf(file, "Ring %s: size %4d, busy %4d (prod %4d, cons %4d)\n", \
-                       name, (unsigned)(ring)->size, \
-                       (unsigned)RING_BUSY((ring)), \
-                       (unsigned)*(ring)->producer, (unsigned)*(ring)->consumer)
+               (void)fprintf(file, "Ring %s: size %4d, busy %4d (prod %4d, cons %4d)\n", \
+                             name, (unsigned)(ring)->size, \
+                             (unsigned)RING_BUSY((ring)), \
+                             (unsigned)*(ring)->producer, (unsigned)*(ring)->consumer)
 
        const int rx_busyf = RING_BUSY(&socket->umem->fq) + RING_BUSY(&socket->rx);
-       fprintf(file, "\nLOST RX frames: %4d", (int)(socket->umem->ring_size - rx_busyf));
+       (void)fprintf(file, "\nLOST RX frames: %4d", (int)(socket->umem->ring_size - rx_busyf));
 
        const int tx_busyf = RING_BUSY(&socket->umem->cq) + RING_BUSY(&socket->tx);
        const int tx_freef = socket->umem->tx_free_count;
-       fprintf(file, "\nLOST TX frames: %4d\n", (int)(socket->umem->ring_size - tx_busyf - tx_freef));
+       (void)fprintf(file, "\nLOST TX frames: %4d\n", (int)(socket->umem->ring_size - tx_busyf - tx_freef));
 
        RING_PRINFO("FQ", &socket->umem->fq);
        RING_PRINFO("RX", &socket->rx);
        RING_PRINFO("TX", &socket->tx);
        RING_PRINFO("CQ", &socket->umem->cq);
-       fprintf(file, "TX free frames: %4d\n", tx_freef);
+       (void)fprintf(file, "TX free frames: %4d\n", tx_freef);
 }
 
 _public_
index 78a68ef9be7444d66fc9fd765271fb31ad449aa0..94567c8e8522fedfd22dde97f22683ba5002a12b 100644 (file)
@@ -163,7 +163,7 @@ static size_t get_resolv_nameservers(list_t *servers, const char *def_port)
        }
 
        // Close config file.
-       fclose(f);
+       (void)fclose(f);
 
        // Return number of servers.
        return list_size(servers);
index a814e1a55f20591494a478c4ef57b24d8a8a93d3..4c10e4add828c305fd5989f86ed8ccc0781b0f0c 100644 (file)
@@ -544,7 +544,7 @@ int main(int argc, char **argv)
        /* Now check if we want to daemonize. */
        if (daemonize) {
                if (make_daemon(1, 0) != 0) {
-                       fprintf(stderr, "Daemonization failed, shutting down...\n");
+                       (void)fprintf(stderr, "Daemonization failed, shutting down...\n");
                        return EXIT_FAILURE;
                }
        }
index a30ac08d26b2126258d45fb3cb125449dd018720..8ca0e69c60cf26518144a41a6a0846db86a35890 100644 (file)
@@ -577,7 +577,7 @@ int knsupdate_exec(knsupdate_params_t *params)
                        break;
                }
                ret = process_lines(params, fp);
-               fclose(fp);
+               (void)fclose(fp);
                if (ret != KNOT_EOK) {
                        break;
                }
index fabb4f3abb02e9655850e3009a83b566aacd119c..77fbe90ccfa9da2326d9d72787bbbf292f47f76e 100644 (file)
@@ -219,12 +219,12 @@ bool load_queries(const input_t *input, uint16_t edns_size, uint16_t msgid, size
        }
 
        free(bufs);
-       fclose(f);
+       (void)fclose(f);
        return true;
 
 fail:
        free_global_payloads();
        free(bufs);
-       fclose(f);
+       (void)fclose(f);
        return false;
 }
index 6a6c59e10464ce0a8f06e75dd147b66e9914d2b6..edba74f8cf219c38d54d522964e4f82628296176 100644 (file)
@@ -35,9 +35,9 @@ static void err_callback(sem_handler_t *handler, const zone_contents_t *zone,
                owner = "";
        }
 
-       fprintf(stderr, "[%s] %s%s%s\n", owner, sem_error_msg(error),
-              (data != NULL ? " "  : ""),
-              (data != NULL ? data : ""));
+       (void)fprintf(stderr, "[%s] %s%s%s\n", owner, sem_error_msg(error),
+                     (data != NULL ? " "  : ""),
+                     (data != NULL ? data : ""));
 
        stats->errors[error]++;
        stats->error_count++;
@@ -45,10 +45,10 @@ static void err_callback(sem_handler_t *handler, const zone_contents_t *zone,
 
 static void print_statistics(err_handler_stats_t *stats)
 {
-       fprintf(stderr, "\nError summary:\n");
+       (void)fprintf(stderr, "\nError summary:\n");
        for (sem_error_t i = 0; i <= SEM_ERR_UNKNOWN; ++i) {
                if (stats->errors[i] > 0) {
-                       fprintf(stderr, "%4u\t%s\n", stats->errors[i], sem_error_msg(i));
+                       (void)fprintf(stderr, "%4u\t%s\n", stats->errors[i], sem_error_msg(i));
                }
        }
 }
@@ -96,7 +96,7 @@ int zone_check(const char *zone_file, const knot_dname_t *zone_name, bool zonemd
        if (stats.error_count > 0) {
                print_statistics(&stats);
                if (stats.handler.error) {
-                       fprintf(stderr, "\n");
+                       (void)fprintf(stderr, "\n");
                        ERR2("serious semantic error detected");
                        ret = KNOT_EINVAL;
                } else {
@@ -108,7 +108,7 @@ int zone_check(const char *zone_file, const knot_dname_t *zone_name, bool zonemd
                ret = zone_contents_digest_verify(contents);
                if (ret != KNOT_EOK) {
                        if (stats.error_count > 0 && !stats.handler.error) {
-                               fprintf(stderr, "\n");
+                               (void)fprintf(stderr, "\n");
                        }
                        ERR2("invalid ZONEMD");
                }
@@ -116,7 +116,7 @@ int zone_check(const char *zone_file, const knot_dname_t *zone_name, bool zonemd
 
        if (print) {
                if (ret != KNOT_EOK) {
-                       fprintf(stderr, "\n");
+                       (void)fprintf(stderr, "\n");
                }
                printf(";; Zone dump (Knot DNS %s)\n", PACKAGE_VERSION);
                zone_dump_text(contents, NULL, stdout, false, NULL);