[vlc-devel] [PATCH] tests: replace setenv() with putenv() for static values

Steve Lhomme robux4 at videolabs.io
Fri Sep 30 09:46:20 CEST 2016


Since setenv() is leaky in the compat library this is a better choice.

Also that avoids having to link with the compatibility library for some tests.
---
 bin/vlc.c                    | 8 ++++----
 test/libvlc/test.h           | 2 +-
 test/modules/keystore/test.c | 2 +-
 test/modules/misc/tls.c      | 2 +-
 test/src/interface/dialog.c  | 2 +-
 test/src/misc/keystore.c     | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bin/vlc.c b/bin/vlc.c
index 0a33a0f..83e5991 100644
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -124,15 +124,15 @@ int main( int i_argc, const char *ppsz_argv[] )
 
 #ifndef NDEBUG
     /* Activate malloc checking routines to detect heap corruptions. */
-    setenv ("MALLOC_CHECK_", "2", 1);
+    putenv ("MALLOC_CHECK_=2");
 
     /* Disable the ugly Gnome crash dialog so that we properly segfault */
-    setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1);
+    putenv ("GNOME_DISABLE_CRASH_DIALOG=1");
 #endif
 
 #ifdef TOP_BUILDDIR
-    setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
-    setenv ("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);
+    putenv ("VLC_PLUGIN_PATH="TOP_BUILDDIR"/modules");
+    putenv ("VLC_DATA_PATH="TOP_SRCDIR"/share");
 #endif
 
     /* Clear the X.Org startup notification ID. Otherwise the UI might try to
diff --git a/test/libvlc/test.h b/test/libvlc/test.h
index 4e8356a..379d587 100644
--- a/test/libvlc/test.h
+++ b/test/libvlc/test.h
@@ -68,7 +68,7 @@ static inline void test_init (void)
 {
     (void)test_default_sample; /* This one may not be used */
     alarm (10); /* Make sure "make check" does not get stuck */
-    setenv( "VLC_PLUGIN_PATH", "../modules", 1 );
+    putenv( "VLC_PLUGIN_PATH=../modules" );
 }
 
 #endif /* TEST_H */
diff --git a/test/modules/keystore/test.c b/test/modules/keystore/test.c
index 0ddb827..bfe7638 100644
--- a/test/modules/keystore/test.c
+++ b/test/modules/keystore/test.c
@@ -303,7 +303,7 @@ main(int i_argc, char *ppsz_argv[])
     if (!b_test_all)
         alarm(3);
 
-    setenv("VLC_PLUGIN_PATH", "../modules", 1);
+    putenv("VLC_PLUGIN_PATH=../modules");
 
     /* Create a dummy libvlc to initialize module bank, needed by module_exists */
     libvlc_instance_t *p_libvlc = libvlc_new(0, NULL);
diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c
index 60898c6..81d87d3 100644
--- a/test/modules/misc/tls.c
+++ b/test/modules/misc/tls.c
@@ -158,7 +158,7 @@ int main(void)
 
     assert(!strncmp(homedir, "/tmp/vlc-test-", 14));
     setenv("HOME", homedir, 1);
-    setenv("VLC_PLUGIN_PATH", "../modules", 1);
+    putenv("VLC_PLUGIN_PATH=../modules");
 
     vlc = libvlc_new(0, NULL);
     assert(vlc != NULL);
diff --git a/test/src/interface/dialog.c b/test/src/interface/dialog.c
index d47ea80..65feadc 100644
--- a/test/src/interface/dialog.c
+++ b/test/src/interface/dialog.c
@@ -286,7 +286,7 @@ main(int i_argc, char *ppsz_argv[])
     if (!b_test_all)
         alarm(10);
 
-    setenv("VLC_PLUGIN_PATH", "../modules", 1);
+    putenv("VLC_PLUGIN_PATH=../modules");
 
     libvlc_instance_t *p_libvlc = libvlc_new(0, NULL);
     assert(p_libvlc != NULL);
diff --git a/test/src/misc/keystore.c b/test/src/misc/keystore.c
index a59f6f4..d62064d 100644
--- a/test/src/misc/keystore.c
+++ b/test/src/misc/keystore.c
@@ -301,7 +301,7 @@ create_libvlc(int i_vlc_argc, const char *const *ppsz_vlc_argv)
 int
 main(void)
 {
-    setenv("VLC_PLUGIN_PATH", "../modules", 1);
+    putenv("VLC_PLUGIN_PATH=../modules");
 
     printf("creating tmp plaintext keystore file\n");
     char psz_tmp_path[] = "/tmp/libvlc_XXXXXX";
-- 
2.8.2



More information about the vlc-devel mailing list