From 7902c892dadffb1a2ef560047df740842c551498 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Tue, 15 Apr 2025 02:31:28 +0200
Subject: [PATCH 12/12] fftools/textformat/avtextformat: Make close functions
 return void

Just like normal close functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/ffprobe.c                  | 14 +++-----------
 fftools/textformat/avtextformat.c  | 11 ++++-------
 fftools/textformat/avtextformat.h  |  2 +-
 fftools/textformat/avtextwriters.h |  2 +-
 4 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0953a029a0..f5c83925b9 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3077,7 +3077,7 @@ int main(int argc, char **argv)
     AVTextWriterContext *wctx;
     char *buf;
     char *f_name = NULL, *f_args = NULL;
-    int ret, input_ret, i;
+    int ret, i;
 
     init_dynload();
 
@@ -3197,19 +3197,11 @@ int main(int argc, char **argv)
                 show_error(tctx, ret);
         }
 
-        input_ret = ret;
-
         avtext_print_section_footer(tctx);
 
-        ret = avtextwriter_context_close(&wctx);
-        if (ret < 0)
-            av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing writer): %s\n", av_err2str(ret));
-
-        ret = avtext_context_close(&tctx);
-        if (ret < 0)
-            av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret));
+        avtextwriter_context_close(&wctx);
 
-        ret = FFMIN(ret, input_ret);
+        avtext_context_close(&tctx);
     }
 
 end:
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 5abf81194e..44085fc87a 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -99,14 +99,13 @@ static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
         av_bprintf(bp, "%02X", ubuf[i]);
 }
 
-int avtext_context_close(AVTextFormatContext **ptctx)
+void avtext_context_close(AVTextFormatContext **ptctx)
 {
     AVTextFormatContext *tctx = *ptctx;
     int i;
-    int ret = 0;
 
     if (!tctx)
-        return AVERROR(EINVAL);
+        return;
 
     av_hash_freep(&tctx->hash);
 
@@ -123,7 +122,6 @@ int avtext_context_close(AVTextFormatContext **ptctx)
     av_freep(&tctx->priv);
     av_opt_free(tctx);
     av_freep(ptctx);
-    return ret;
 }
 
 
@@ -584,13 +582,13 @@ static const AVClass textwriter_class = {
 };
 
 
-int avtextwriter_context_close(AVTextWriterContext **pwctx)
+void avtextwriter_context_close(AVTextWriterContext **pwctx)
 {
     AVTextWriterContext *wctx = *pwctx;
     int ret = 0;
 
     if (!wctx)
-        return AVERROR(EINVAL);
+        return;
 
     if (wctx->writer) {
         if (wctx->writer->uninit)
@@ -600,7 +598,6 @@ int avtextwriter_context_close(AVTextWriterContext **pwctx)
     }
     av_freep(&wctx->priv);
     av_freep(pwctx);
-    return ret;
 }
 
 
diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h
index 9fad3caae5..c2c56dc1a7 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -132,7 +132,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
                         int show_optional_fields,
                         char *show_data_hash);
 
-int avtext_context_close(AVTextFormatContext **tctx);
+void avtext_context_close(AVTextFormatContext **tctx);
 
 
 void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id);
diff --git a/fftools/textformat/avtextwriters.h b/fftools/textformat/avtextwriters.h
index 87b0024ba1..c99d6b3548 100644
--- a/fftools/textformat/avtextwriters.h
+++ b/fftools/textformat/avtextwriters.h
@@ -55,7 +55,7 @@ typedef struct AVTextWriterContext {
 
 int avtextwriter_context_open(AVTextWriterContext **pwctx, const AVTextWriter *writer);
 
-int avtextwriter_context_close(AVTextWriterContext **pwctx);
+void avtextwriter_context_close(AVTextWriterContext **pwctx);
 
 int avtextwriter_create_stdout(AVTextWriterContext **pwctx);
 
-- 
2.45.2