diff mbox series

[FFmpeg-devel,3/6] avformat/tee: Constify AVDictionaryEntry* pointee where possible

Message ID AS8P250MB0744973ED04B3FA8F778ED958FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Headers show
Series [FFmpeg-devel,1/6] avformat/utils: Use static mutexes instead of ff_lock_avformat() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 fail Make failed

Commit Message

Andreas Rheinhardt May 17, 2024, 3:25 p.m. UTC
This is in preparation for using av_dict_iterate().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/tee.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Marvin Scholz May 17, 2024, 3:42 p.m. UTC | #1
On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:

> This is in preparation for using av_dict_iterate().
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/tee.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 1cbbb80dbb..87159681ed 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>  {
>      int i, ret;
>      AVDictionary *options = NULL, *bsf_options = NULL;
> -    AVDictionaryEntry *entry;
> +    const AVDictionaryEntry *entry;
>      char *filename;
>      char *format = NULL, *select = NULL, *on_fail = NULL;
>      char *use_fifo = NULL, *fifo_options_str = NULL;
> @@ -172,8 +172,9 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>          return ret;
>
>  #define CONSUME_OPTION(option, field, action) do {                      \
> -        if ((entry = av_dict_get(options, option, NULL, 0))) {          \
> -            field = entry->value;                                       \
> +        AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
> +        if (en) {                                                       \
> +            field = en->value;                                          \
>              { action }                                                  \
>              av_dict_set(&options, option, NULL, 0);                     \
>          }                                                               \
> -- 
> 2.40.1
>

LGTM, thanks!

> _______________________________________________
> 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".
Andreas Rheinhardt May 17, 2024, 4:17 p.m. UTC | #2
Andreas Rheinhardt:
> This is in preparation for using av_dict_iterate().
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/tee.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 1cbbb80dbb..87159681ed 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>  {
>      int i, ret;
>      AVDictionary *options = NULL, *bsf_options = NULL;
> -    AVDictionaryEntry *entry;
> +    const AVDictionaryEntry *entry;
>      char *filename;
>      char *format = NULL, *select = NULL, *on_fail = NULL;
>      char *use_fifo = NULL, *fifo_options_str = NULL;
> @@ -172,8 +172,9 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>          return ret;
>  
>  #define CONSUME_OPTION(option, field, action) do {                      \
> -        if ((entry = av_dict_get(options, option, NULL, 0))) {          \
> -            field = entry->value;                                       \
> +        AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
> +        if (en) {                                                       \
> +            field = en->value;                                          \
>              { action }                                                  \
>              av_dict_set(&options, option, NULL, 0);                     \
>          }                                                               \

Added the following necessary diff from the next patch locally:

-                   entry->value = NULL; /* prevent it from being freed */)
+                   en->value = NULL; /* prevent it from being freed */)

- Andreas
diff mbox series

Patch

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 1cbbb80dbb..87159681ed 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -158,7 +158,7 @@  static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
 {
     int i, ret;
     AVDictionary *options = NULL, *bsf_options = NULL;
-    AVDictionaryEntry *entry;
+    const AVDictionaryEntry *entry;
     char *filename;
     char *format = NULL, *select = NULL, *on_fail = NULL;
     char *use_fifo = NULL, *fifo_options_str = NULL;
@@ -172,8 +172,9 @@  static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
         return ret;
 
 #define CONSUME_OPTION(option, field, action) do {                      \
-        if ((entry = av_dict_get(options, option, NULL, 0))) {          \
-            field = entry->value;                                       \
+        AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
+        if (en) {                                                       \
+            field = en->value;                                          \
             { action }                                                  \
             av_dict_set(&options, option, NULL, 0);                     \
         }                                                               \