[FFmpeg-devel] [PATCH 1/2] Refactor libavutil/parseutils.c

Michael Niedermayer michael at niedermayer.cc
Thu Mar 24 03:56:33 CET 2016


On Wed, Mar 23, 2016 at 03:32:56PM +0000, Petru Rares Sincraian wrote:
> All tests were in the main method which produces a long main. Now, each test
> is in his own method.
> 
> I think this produces a more clear code and follows more with the main
> priority of FFmpeg "simplicity and small code size"
> ---
>  libavutil/parseutils.c | 338 +++++++++++++++++++++++++------------------------
>  1 file changed, 175 insertions(+), 163 deletions(-)

applied

for reference the change without whitespace differences:


diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 0097bec..43bd4eb 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -749,9 +749,7 @@ static uint32_t av_get_random_seed_deterministic(void)
     return randomv = randomv * 1664525 + 1013904223;
 }

-int main(void)
-{
-    printf("Testing av_parse_video_rate()\n");
+static void test_av_parse_video_rate(void)
     {
         int i;
         static const char *const rates[] = {
@@ -791,7 +789,7 @@ int main(void)
         }
     }

-    printf("\nTesting av_parse_color()\n");
+static void test_av_parse_color(void)
     {
         int i;
         uint8_t rgba[4];
@@ -845,7 +843,7 @@ int main(void)
         }
     }

-    printf("\nTesting av_small_strptime()\n");
+static void test_av_small_strptime(void)
     {
         int i;
         struct tm tm = { 0 };
@@ -874,7 +872,7 @@ int main(void)
         }
     }

-    printf("\nTesting av_parse_time()\n");
+static void test_av_parse_time(void)
     {
         int i;
         int64_t tv;
@@ -924,6 +922,20 @@ int main(void)
         }
     }

+int main(void)
+{
+    printf("Testing av_parse_video_rate()\n");
+    test_av_parse_video_rate();
+
+    printf("\nTesting av_parse_color()\n");
+    test_av_parse_color();
+
+    printf("\nTesting av_small_strptime()\n");
+    test_av_small_strptime();
+
+    printf("\nTesting av_parse_time()\n");
+    test_av_parse_time();
+
     return 0;
 }

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160324/c73a5e65/attachment.sig>


More information about the ffmpeg-devel mailing list