On Fri, Aug 17, 2012 at 07:53:46PM +0200, Anton Khirnov wrote:
> On Fri, 17 Aug 2012 17:59:08 +0200, Diego Biurrun <[email protected]> wrote:
> > On Wed, Aug 15, 2012 at 10:37:18AM +0200, Anton Khirnov wrote:
> > > show_foo() functions are declared as void show_foo(void), but called as
> > > int show_foo(const char*, const char*).
> > > ---
> > >  avconv_opt.c           |    3 ++-
> > >  avplay.c               |    6 ++++--
> > >  avprobe.c              |    3 ++-
> > >  cmdutils.c             |   27 +++++++++++++++++++--------
> > >  cmdutils.h             |   16 ++++++++--------
> > >  cmdutils_common_opts.h |   32 ++++++++++++++++----------------
> > >  6 files changed, 51 insertions(+), 36 deletions(-)
> > 
> > Adding unused parameters just to match the function pointer signature
> > feels wrong.  Why don't you add another function pointer with matching
> > signature to the union in cmdutils.h?
> 
> What exactly feels wrong about it? It looks very right to me.
> 
> Your suggestion is more code with no benefit.

$attached does not look like more code to me.

Diego
>From a39fc63f50d2c08159570e5f4f75b630a9c2079e Mon Sep 17 00:00:00 2001
From: Diego Biurrun <[email protected]>
Date: Fri, 17 Aug 2012 23:20:05 +0200
Subject: [PATCH] cmdutils: Add function pointer with correct signature for show_ functions

---
 cmdutils.h             |    1 +
 cmdutils_common_opts.h |   24 ++++++++++++------------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/cmdutils.h b/cmdutils.h
index f013c2a..72aec1e 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -148,6 +148,7 @@ typedef struct {
         void *dst_ptr;
         int (*func_arg)(const char *, const char *);
         int (*func2_arg)(void *, const char *, const char *);
+        void (*show)(void);
         size_t off;
     } u;
     const char *help;
diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
index 1158afa..1b52774 100644
--- a/cmdutils_common_opts.h
+++ b/cmdutils_common_opts.h
@@ -1,15 +1,15 @@
-    { "L", OPT_EXIT, {(void*)show_license}, "show license" },
-    { "h", OPT_EXIT, {(void*)show_help}, "show help" },
-    { "?", OPT_EXIT, {(void*)show_help}, "show help" },
-    { "help", OPT_EXIT, {(void*)show_help}, "show help" },
-    { "-help", OPT_EXIT, {(void*)show_help}, "show help" },
-    { "version", OPT_EXIT, {(void*)show_version}, "show version" },
-    { "formats"  , OPT_EXIT, {(void*)show_formats  }, "show available formats" },
-    { "codecs"   , OPT_EXIT, {(void*)show_codecs   }, "show available codecs" },
-    { "bsfs"     , OPT_EXIT, {(void*)show_bsfs     }, "show available bit stream filters" },
-    { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
-    { "filters",   OPT_EXIT, {(void*)show_filters  }, "show available filters" },
-    { "pix_fmts" , OPT_EXIT, {(void*)show_pix_fmts }, "show available pixel formats" },
+    { "L",           OPT_EXIT, { .show = show_license },         "show license" },
+    { "h",           OPT_EXIT, { .show = show_help },            "show help" },
+    { "?",           OPT_EXIT, { .show = show_help },            "show help" },
+    { "help",        OPT_EXIT, { .show = show_help },            "show help" },
+    { "-help",       OPT_EXIT, { .show = show_help },            "show help" },
+    { "version",     OPT_EXIT, { .show = show_version },         "show version" },
+    { "formats",     OPT_EXIT, { .show = show_formats },         "show available formats" },
+    { "codecs",      OPT_EXIT, { .show = show_codecs },          "show available codecs" },
+    { "bsfs",        OPT_EXIT, { .show = show_bsfs },            "show available bit stream filters" },
+    { "protocols",   OPT_EXIT, { .show = show_protocols },       "show available protocols" },
+    { "filters",     OPT_EXIT, { .show = show_filters },         "show available filters" },
+    { "pix_fmts" ,   OPT_EXIT, { .show = show_pix_fmts },        "show available pixel formats" },
     { "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
     { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
     { "v", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
-- 
1.7.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to