diff mbox series

[FFmpeg-devel,08/17] avformat/webm_chunk: Use appropriate initializer for AV_OPT_TYPE_STRING

Message ID 20200302044445.14842-4-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/17] avformat: Use correct error in case muxer is not found | expand

Checks

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

Commit Message

Andreas Rheinhardt March 2, 2020, 4:44 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/webm_chunk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Moritz Barsnick March 4, 2020, 9:49 a.m. UTC | #1
On Mon, Mar 02, 2020 at 05:44:36 +0100, Andreas Rheinhardt wrote:
> -    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
> +    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },

I found some 19 or so further occurences of this pattern[*]. Are they
worth "fixing", or is it a purely cosmetic thing?

[*] $ find -name "*.[ch]" -print0 | xargs -0 grep -Pn 'AV_OPT_TYPE_STRING,\s*{\s*0\s*}'

Cheers,
Moritz
Andreas Rheinhardt March 10, 2020, 8:12 a.m. UTC | #2
Moritz Barsnick:
> On Mon, Mar 02, 2020 at 05:44:36 +0100, Andreas Rheinhardt wrote:
>> -    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
>> +    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
> 
> I found some 19 or so further occurences of this pattern[*]. Are they
> worth "fixing", or is it a purely cosmetic thing?
> 
> [*] $ find -name "*.[ch]" -print0 | xargs -0 grep -Pn 'AV_OPT_TYPE_STRING,\s*{\s*0\s*}'
> 
> Cheers,
> Moritz

It won't make a difference as long as FFmpeg doesn't support systems
where a pointer whose object representation consist of zeroes alone is
different from NULL or where sizeof(char *) > sizeof(int64_t); but it
is IMO nevertheless worth changing, just as it is good practice to use
NULL for pointers instead of 0. So if you want to make a commit
changing all of those occurences, then go ahead.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 63c00d22e4..08d825449e 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -267,7 +267,7 @@  fail:
 #define OFFSET(x) offsetof(WebMChunkContext, x)
 static const AVOption options[] = {
     { "chunk_start_index",  "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
+    { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
     { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
     { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0, AV_OPT_FLAG_ENCODING_PARAM },
     { NULL },