* [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void"
@ 2025-05-07 12:54 Marton Balint
2025-05-07 12:54 ` [FFmpeg-devel] [PATCH 2/2] fftools/textformat: correctly propagate uninit error codes Marton Balint
2025-05-15 21:28 ` [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
0 siblings, 2 replies; 3+ messages in thread
From: Marton Balint @ 2025-05-07 12:54 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
This reverts commit 7684243fbe6e84fecb4a039195d5fda8a006a2a4 and
a888975a3c25760027cd59932f5c1ad04368db8b.
---
fftools/ffprobe.c | 14 +++++++++++---
fftools/textformat/avtextformat.c | 12 ++++++++----
fftools/textformat/avtextformat.h | 2 +-
fftools/textformat/avtextwriters.h | 2 +-
4 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index d980d4e64f..a2342ec894 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, i;
+ int ret, input_ret, i;
init_dynload();
@@ -3199,11 +3199,19 @@ int main(int argc, char **argv)
show_error(tctx, ret);
}
+ input_ret = ret;
+
avtext_print_section_footer(tctx);
- avtextwriter_context_close(&wctx);
+ 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));
- avtext_context_close(&tctx);
+ ret = FFMIN(ret, input_ret);
}
end:
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 9200b9b1ad..5abf81194e 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -99,13 +99,14 @@ static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
av_bprintf(bp, "%02X", ubuf[i]);
}
-void avtext_context_close(AVTextFormatContext **ptctx)
+int avtext_context_close(AVTextFormatContext **ptctx)
{
AVTextFormatContext *tctx = *ptctx;
int i;
+ int ret = 0;
if (!tctx)
- return;
+ return AVERROR(EINVAL);
av_hash_freep(&tctx->hash);
@@ -122,6 +123,7 @@ void avtext_context_close(AVTextFormatContext **ptctx)
av_freep(&tctx->priv);
av_opt_free(tctx);
av_freep(ptctx);
+ return ret;
}
@@ -582,12 +584,13 @@ static const AVClass textwriter_class = {
};
-void avtextwriter_context_close(AVTextWriterContext **pwctx)
+int avtextwriter_context_close(AVTextWriterContext **pwctx)
{
AVTextWriterContext *wctx = *pwctx;
+ int ret = 0;
if (!wctx)
- return;
+ return AVERROR(EINVAL);
if (wctx->writer) {
if (wctx->writer->uninit)
@@ -597,6 +600,7 @@ void 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 c2c56dc1a7..9fad3caae5 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);
-void avtext_context_close(AVTextFormatContext **tctx);
+int 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 c99d6b3548..87b0024ba1 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);
-void avtextwriter_context_close(AVTextWriterContext **pwctx);
+int avtextwriter_context_close(AVTextWriterContext **pwctx);
int avtextwriter_create_stdout(AVTextWriterContext **pwctx);
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] fftools/textformat: correctly propagate uninit error codes
2025-05-07 12:54 [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
@ 2025-05-07 12:54 ` Marton Balint
2025-05-15 21:28 ` [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
1 sibling, 0 replies; 3+ messages in thread
From: Marton Balint @ 2025-05-07 12:54 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
This allows catching IO errors occuring at file close.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
fftools/textformat/avtextformat.c | 4 ++--
fftools/textformat/avtextformat.h | 2 +-
fftools/textformat/avtextwriters.h | 2 +-
fftools/textformat/tw_avio.c | 6 ++++--
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 5abf81194e..3c9193bb64 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -114,7 +114,7 @@ int avtext_context_close(AVTextFormatContext **ptctx)
if (tctx->formatter) {
if (tctx->formatter->uninit)
- tctx->formatter->uninit(tctx);
+ ret = tctx->formatter->uninit(tctx);
if (tctx->formatter->priv_class)
av_opt_free(tctx->priv);
}
@@ -594,7 +594,7 @@ int avtextwriter_context_close(AVTextWriterContext **pwctx)
if (wctx->writer) {
if (wctx->writer->uninit)
- wctx->writer->uninit(wctx);
+ ret = wctx->writer->uninit(wctx);
if (wctx->writer->priv_class)
av_opt_free(wctx->priv);
}
diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h
index 9fad3caae5..169305927b 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -72,7 +72,7 @@ typedef struct AVTextFormatter {
const char *name;
int (*init) (AVTextFormatContext *tctx);
- void (*uninit)(AVTextFormatContext *tctx);
+ int (*uninit)(AVTextFormatContext *tctx);
void (*print_section_header)(AVTextFormatContext *tctx, const void *data);
void (*print_section_footer)(AVTextFormatContext *tctx);
diff --git a/fftools/textformat/avtextwriters.h b/fftools/textformat/avtextwriters.h
index 87b0024ba1..04e5edcb67 100644
--- a/fftools/textformat/avtextwriters.h
+++ b/fftools/textformat/avtextwriters.h
@@ -38,7 +38,7 @@ typedef struct AVTextWriter {
const char *name;
int (* init)(AVTextWriterContext *wctx);
- void (* uninit)(AVTextWriterContext *wctx);
+ int (* uninit)(AVTextWriterContext *wctx);
void (* writer_w8)(AVTextWriterContext *wctx, int b);
void (* writer_put_str)(AVTextWriterContext *wctx, const char *str);
void (* writer_printf)(AVTextWriterContext *wctx, const char *fmt, ...);
diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c
index 6034f74ec9..35c595f457 100644
--- a/fftools/textformat/tw_avio.c
+++ b/fftools/textformat/tw_avio.c
@@ -36,12 +36,14 @@ typedef struct IOWriterContext {
int close_on_uninit;
} IOWriterContext;
-static av_cold void iowriter_uninit(AVTextWriterContext *wctx)
+static av_cold int iowriter_uninit(AVTextWriterContext *wctx)
{
IOWriterContext *ctx = wctx->priv;
+ int ret = 0;
if (ctx->close_on_uninit)
- avio_closep(&ctx->avio_context);
+ ret = avio_closep(&ctx->avio_context);
+ return ret;
}
static void io_w8(AVTextWriterContext *wctx, int b)
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void"
2025-05-07 12:54 [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
2025-05-07 12:54 ` [FFmpeg-devel] [PATCH 2/2] fftools/textformat: correctly propagate uninit error codes Marton Balint
@ 2025-05-15 21:28 ` Marton Balint
1 sibling, 0 replies; 3+ messages in thread
From: Marton Balint @ 2025-05-15 21:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, 7 May 2025, Marton Balint wrote:
> This reverts commit 7684243fbe6e84fecb4a039195d5fda8a006a2a4 and
> a888975a3c25760027cd59932f5c1ad04368db8b.
Will apply the series.
Regards,
Marton
> ---
> fftools/ffprobe.c | 14 +++++++++++---
> fftools/textformat/avtextformat.c | 12 ++++++++----
> fftools/textformat/avtextformat.h | 2 +-
> fftools/textformat/avtextwriters.h | 2 +-
> 4 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index d980d4e64f..a2342ec894 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, i;
> + int ret, input_ret, i;
>
> init_dynload();
>
> @@ -3199,11 +3199,19 @@ int main(int argc, char **argv)
> show_error(tctx, ret);
> }
>
> + input_ret = ret;
> +
> avtext_print_section_footer(tctx);
>
> - avtextwriter_context_close(&wctx);
> + 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));
>
> - avtext_context_close(&tctx);
> + ret = FFMIN(ret, input_ret);
> }
>
> end:
> diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
> index 9200b9b1ad..5abf81194e 100644
> --- a/fftools/textformat/avtextformat.c
> +++ b/fftools/textformat/avtextformat.c
> @@ -99,13 +99,14 @@ static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
> av_bprintf(bp, "%02X", ubuf[i]);
> }
>
> -void avtext_context_close(AVTextFormatContext **ptctx)
> +int avtext_context_close(AVTextFormatContext **ptctx)
> {
> AVTextFormatContext *tctx = *ptctx;
> int i;
> + int ret = 0;
>
> if (!tctx)
> - return;
> + return AVERROR(EINVAL);
>
> av_hash_freep(&tctx->hash);
>
> @@ -122,6 +123,7 @@ void avtext_context_close(AVTextFormatContext **ptctx)
> av_freep(&tctx->priv);
> av_opt_free(tctx);
> av_freep(ptctx);
> + return ret;
> }
>
>
> @@ -582,12 +584,13 @@ static const AVClass textwriter_class = {
> };
>
>
> -void avtextwriter_context_close(AVTextWriterContext **pwctx)
> +int avtextwriter_context_close(AVTextWriterContext **pwctx)
> {
> AVTextWriterContext *wctx = *pwctx;
> + int ret = 0;
>
> if (!wctx)
> - return;
> + return AVERROR(EINVAL);
>
> if (wctx->writer) {
> if (wctx->writer->uninit)
> @@ -597,6 +600,7 @@ void 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 c2c56dc1a7..9fad3caae5 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);
>
> -void avtext_context_close(AVTextFormatContext **tctx);
> +int 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 c99d6b3548..87b0024ba1 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);
>
> -void avtextwriter_context_close(AVTextWriterContext **pwctx);
> +int avtextwriter_context_close(AVTextWriterContext **pwctx);
>
> int avtextwriter_create_stdout(AVTextWriterContext **pwctx);
>
> --
> 2.43.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-15 21:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-07 12:54 [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
2025-05-07 12:54 ` [FFmpeg-devel] [PATCH 2/2] fftools/textformat: correctly propagate uninit error codes Marton Balint
2025-05-15 21:28 ` [FFmpeg-devel] [PATCH 1/2] Revert "fftools/textformat/avtextformat: Make close functions return void" Marton Balint
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git