diff mbox series

[FFmpeg-devel,14/60] lavfi/vf_signature: use av_err2str to simplify code

Message ID D41CE2FHW1SG.20PXHGZQH7QFB@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,01/60] fftools/ffmpeg_opt: fix variable shadowing | expand

Commit Message

Marvin Scholz Sept. 8, 2024, 6:56 p.m. UTC
No need to explicitly specify the buffer here as it is only
ever passed to av_log, so av_err2str can be used.
---
 libavfilter/vf_signature.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Anton Khirnov Sept. 11, 2024, 11:58 a.m. UTC | #1
Quoting Marvin Scholz (2024-09-08 20:56:38)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavfilter/vf_signature.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
> index f205f6919f..f419522ac6 100644
> --- a/libavfilter/vf_signature.c
> +++ b/libavfilter/vf_signature.c
> @@ -386,9 +386,7 @@ static int xml_export(AVFilterContext *ctx, StreamContext *sc, const char* filen
>      f = avpriv_fopen_utf8(filename, "w");
>      if (!f) {
>          int err = AVERROR(EINVAL);
> -        char buf[128];
> -        av_strerror(err, buf, sizeof(buf));
> -        av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, buf);
> +        av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, av_err2str(err));
>          return err;
>      }
>  
> @@ -500,9 +498,7 @@ static int binary_export(AVFilterContext *ctx, StreamContext *sc, const char* fi
>      f = avpriv_fopen_utf8(filename, "wb");
>      if (!f) {
>          int err = AVERROR(EINVAL);
> -        char buf[128];
> -        av_strerror(err, buf, sizeof(buf));
> -        av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, buf);
> +        av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, av_err2str(err));

The change looks ok, but the original code highly suspicious (should be
errno rather than EINVAL).
diff mbox series

Patch

diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index f205f6919f..f419522ac6 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -386,9 +386,7 @@  static int xml_export(AVFilterContext *ctx, StreamContext *sc, const char* filen
     f = avpriv_fopen_utf8(filename, "w");
     if (!f) {
         int err = AVERROR(EINVAL);
-        char buf[128];
-        av_strerror(err, buf, sizeof(buf));
-        av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, buf);
+        av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, av_err2str(err));
         return err;
     }
 
@@ -500,9 +498,7 @@  static int binary_export(AVFilterContext *ctx, StreamContext *sc, const char* fi
     f = avpriv_fopen_utf8(filename, "wb");
     if (!f) {
         int err = AVERROR(EINVAL);
-        char buf[128];
-        av_strerror(err, buf, sizeof(buf));
-        av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, buf);
+        av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, av_err2str(err));
         av_freep(&buffer);
         return err;
     }