diff mbox series

[FFmpeg-devel,10/10] libavformat/mux, mxfenc: Don't initialize unnecessarily

Message ID 20200331123745.6461-11-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series libavformat/mux patches | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 31, 2020, 12:37 p.m. UTC
When no packet could be output, the interleavement functions
nevertheless initialized the packet destined for output (with the
exception of the data and size fields, making the initialization
pointless), although it will not be used at all. So remove the
initializations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/internal.h | 4 ++--
 libavformat/mux.c      | 1 -
 libavformat/mxfenc.c   | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)

Comments

Marton Balint March 31, 2020, 10:23 p.m. UTC | #1
On Tue, 31 Mar 2020, Andreas Rheinhardt wrote:

> When no packet could be output, the interleavement functions
> nevertheless initialized the packet destined for output (with the
> exception of the data and size fields, making the initialization
> pointless), although it will not be used at all. So remove the
> initializations.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> libavformat/internal.h | 4 ++--
> libavformat/mux.c      | 1 -
> libavformat/mxfenc.c   | 1 -
> 3 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index a861acdc2a..7a01c25ea1 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -504,8 +504,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
>  *            (as if unreferenced) on success.
>  * @param flush 1 if no further packets are available as input and all
>  *              remaining packets should be output
> - * @return 1 if a packet was output, 0 if no packet could be output,
> - *         < 0 if an error occurred
> + * @return 1 if a packet was output, 0 if no packet could be output
> + *         (in which case out may be uninitialized), < 0 if an error occurred
>  */
> int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
>                                  AVPacket *pkt, int flush);
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index acb71b30c9..034cc0b0ab 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1147,7 +1147,6 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
>
>         return 1;
>     } else {
> -        av_init_packet(out);
>         return 0;
>     }
> }
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index bfce531f54..23147e9b84 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -3070,7 +3070,6 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
>         return 1;
>     } else {
>     out:
> -        av_init_packet(out);
>         return 0;
>     }
> }

LGTM.

Thanks,
Marton
diff mbox series

Patch

diff --git a/libavformat/internal.h b/libavformat/internal.h
index a861acdc2a..7a01c25ea1 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -504,8 +504,8 @@  int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
  *            (as if unreferenced) on success.
  * @param flush 1 if no further packets are available as input and all
  *              remaining packets should be output
- * @return 1 if a packet was output, 0 if no packet could be output,
- *         < 0 if an error occurred
+ * @return 1 if a packet was output, 0 if no packet could be output
+ *         (in which case out may be uninitialized), < 0 if an error occurred
  */
 int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
                                  AVPacket *pkt, int flush);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index acb71b30c9..034cc0b0ab 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1147,7 +1147,6 @@  int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
 
         return 1;
     } else {
-        av_init_packet(out);
         return 0;
     }
 }
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index bfce531f54..23147e9b84 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3070,7 +3070,6 @@  static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
         return 1;
     } else {
     out:
-        av_init_packet(out);
         return 0;
     }
 }