[FFmpeg-cvslog] ffprobe: kill initializers with nested union field definition

Stefano Sabatini git at videolan.org
Fri Sep 14 10:57:47 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Sep 13 00:59:49 2012 +0200| [8d0e871f2543e7809a18b64a8181beff5f885d32] | committer: Stefano Sabatini

ffprobe: kill initializers with nested union field definition

The c99-to-c89 converter (for MSVC support) doesn't currently handle
designated initializers or compound literals with nested unions or
structs.

This is apparently the only place where this construct is used in the
FFmpeg codebase.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d0e871f2543e7809a18b64a8181beff5f885d32
---

 ffprobe.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index c9f973d..a0aee83 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -356,7 +356,10 @@ static void writer_print_time(WriterContext *wctx, const char *key,
             writer_print_string(wctx, key, "N/A", 1);
         } else {
             double d = ts * av_q2d(*time_base);
-            value_string(buf, sizeof(buf), (struct unit_value){.val.d=d, .unit=unit_second_str});
+            struct unit_value uv;
+            uv.val.d = d;
+            uv.unit = unit_second_str;
+            value_string(buf, sizeof(buf), uv);
             writer_print_string(wctx, key, buf, 0);
         }
     }
@@ -1442,8 +1445,13 @@ static void writer_register_all(void)
 #define print_ts(k, v)          writer_print_ts(w, k, v, 0)
 #define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
 #define print_duration_ts(k, v)       writer_print_ts(w, k, v, 1)
-#define print_val(k, v, u)      writer_print_string(w, k, \
-    value_string(val_str, sizeof(val_str), (struct unit_value){.val.i = v, .unit=u}), 0)
+#define print_val(k, v, u) do {                                     \
+    struct unit_value uv;                                           \
+    uv.val.i = v;                                                   \
+    uv.unit = u;                                                    \
+    writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
+} while (0)
+
 #define print_section_header(s) writer_print_section_header(w, s)
 #define print_section_footer(s) writer_print_section_footer(w, s)
 #define show_tags(metadata)     writer_show_tags(w, metadata)



More information about the ffmpeg-cvslog mailing list