[FFmpeg-devel] [PATCH 3/5] all: use function pointer instead of void * data pointer

Ganesh Ajjanagadde gajjanagadde at gmail.com
Sat Oct 24 15:28:52 CEST 2015


ISO C does not guarantee that functions and data live in the same
address space. It is thus (strictly speaking) illegal to assign to a
void * (which is a data pointer) from a function pointer.

Found by enabling -Wpedantic on clang 3.7.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 ffmpeg_opt.c              | 8 ++++----
 libavcodec/hevc.c         | 2 +-
 libavfilter/vf_drawtext.c | 2 +-
 libavfilter/vf_lut.c      | 6 +++---
 libavformat/async.c       | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 8f6416c..131dd89 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -3116,7 +3116,7 @@ const OptionDef options[] = {
     { "target",         HAS_ARG | OPT_PERFILE | OPT_OUTPUT,          { .func_arg = opt_target },
         "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
         "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
-    { "vsync",          HAS_ARG | OPT_EXPERT,                        { opt_vsync },
+    { "vsync",          HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_vsync },
         "video sync method", "" },
     { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT,      { &frame_drop_threshold },
         "frame drop threshold", "" },
@@ -3240,9 +3240,9 @@ const OptionDef options[] = {
         "this option is deprecated, use the yadif filter instead" },
     { "psnr",         OPT_VIDEO | OPT_BOOL | OPT_EXPERT,                         { &do_psnr },
         "calculate PSNR of compressed frames" },
-    { "vstats",       OPT_VIDEO | OPT_EXPERT ,                                   { &opt_vstats },
+    { "vstats",       OPT_VIDEO | OPT_EXPERT ,                                   { .func_arg = opt_vstats },
         "dump video coding statistics to file" },
-    { "vstats_file",  OPT_VIDEO | HAS_ARG | OPT_EXPERT ,                         { opt_vstats_file },
+    { "vstats_file",  OPT_VIDEO | HAS_ARG | OPT_EXPERT ,                         { .func_arg = opt_vstats_file },
         "dump video coding statistics to file", "file" },
     { "vf",           OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_OUTPUT,           { .func_arg = opt_video_filters },
         "set video filters", "filter_graph" },
@@ -3352,7 +3352,7 @@ const OptionDef options[] = {
         "set the initial demux-decode delay", "seconds" },
     { "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver },
         "override the options from ffserver", "" },
-    { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { opt_sdp_file },
+    { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file },
         "specify a file in which to print sdp information", "file" },
 
     { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index cd49718..4b3f199 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2511,7 +2511,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal)
     }
 
     if (s->ps.pps->entropy_coding_sync_enabled_flag)
-        s->avctx->execute2(s->avctx, (void *) hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1);
+        s->avctx->execute2(s->avctx, hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1);
 
     for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
         res += ret[i];
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 8e21693..5c4676e 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1087,7 +1087,7 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
             continue;
 
         dummy.code = code;
-        glyph = av_tree_find(s->glyphs, &dummy, (void *)glyph_cmp, NULL);
+        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);
 
         bitmap = borderw ? glyph->border_bitmap : glyph->bitmap;
 
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index 7d708f6..f0a2aba 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -186,9 +186,9 @@ static double compute_gammaval709(void *opaque, double gamma)
 }
 
 static double (* const funcs1[])(void *, double) = {
-    (void *)clip,
-    (void *)compute_gammaval,
-    (void *)compute_gammaval709,
+    clip,
+    compute_gammaval,
+    compute_gammaval709,
     NULL
 };
 
diff --git a/libavformat/async.c b/libavformat/async.c
index 9fac84a..f4474b8 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -224,7 +224,7 @@ static void *async_buffer_task(void *arg)
         pthread_mutex_unlock(&c->mutex);
 
         to_copy = FFMIN(4096, fifo_space);
-        ret = ring_generic_write(ring, (void *)h, to_copy, (void *)wrapped_url_read);
+        ret = ring_generic_write(ring, (void *)h, to_copy, wrapped_url_read);
 
         pthread_mutex_lock(&c->mutex);
         if (ret <= 0) {
-- 
2.6.2



More information about the ffmpeg-devel mailing list