From fbb2f0dae77483dd0c13cf90aa346d2010ffbe9a Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 13 Jun 2017 20:10:17 +0000 Subject: [PATCH] Port: replace setenv() by g_setenv() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- cli/babeltrace.c | 6 +++--- include/babeltrace/compat/utc-internal.h | 5 +++-- tests/lib/test-plugin-plugins/minimal.c | 4 ++-- tests/lib/test_plugin.c | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cli/babeltrace.c b/cli/babeltrace.c index a058bceb..ae8aacfc 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -2573,9 +2573,9 @@ void set_auto_log_levels(struct bt_config *cfg) while (*env_var_name) { if (!getenv(*env_var_name)) { if (cfg->verbose) { - setenv(*env_var_name, "I", 1); + g_setenv(*env_var_name, "I", 1); } else if (cfg->debug) { - setenv(*env_var_name, "V", 1); + g_setenv(*env_var_name, "V", 1); } else { char val[2] = { 0 }; @@ -2584,7 +2584,7 @@ void set_auto_log_levels(struct bt_config *cfg) * explicitly specified. */ val[0] = cfg->log_level; - setenv(*env_var_name, val, 1); + g_setenv(*env_var_name, val, 1); } } diff --git a/include/babeltrace/compat/utc-internal.h b/include/babeltrace/compat/utc-internal.h index d78a1885..db3035a3 100644 --- a/include/babeltrace/compat/utc-internal.h +++ b/include/babeltrace/compat/utc-internal.h @@ -46,6 +46,7 @@ time_t bt_timegm(struct tm *tm) #include #include +#include /* * Note: Below implementation of timegm() is not thread safe @@ -76,11 +77,11 @@ time_t bt_timegm(struct tm *tm) } /* Temporarily setting TZ to 1 for UTC */ - setenv("TZ", "", 1); + g_setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) { - setenv("TZ", tz, 1); + g_setenv("TZ", tz, 1); free(tz); } else { unsetenv("TZ"); diff --git a/tests/lib/test-plugin-plugins/minimal.c b/tests/lib/test-plugin-plugins/minimal.c index c78862b0..6dec80aa 100644 --- a/tests/lib/test-plugin-plugins/minimal.c +++ b/tests/lib/test-plugin-plugins/minimal.c @@ -20,13 +20,13 @@ static enum bt_plugin_status plugin_init(struct bt_plugin *plugin) { - setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1); + g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1); return BT_PLUGIN_STATUS_OK; } static enum bt_plugin_status plugin_exit(void) { - setenv("BT_TEST_PLUGIN_EXIT_CALLED", "1", 1); + g_setenv("BT_TEST_PLUGIN_EXIT_CALLED", "1", 1); return BT_PLUGIN_STATUS_OK; } diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index 874a11db..1fb3c6dd 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -49,8 +49,8 @@ static int check_env_var(const char *name) static void reset_test_plugin_env_vars(void) { - setenv("BT_TEST_PLUGIN_INIT_CALLED", "0", 1); - setenv("BT_TEST_PLUGIN_EXIT_CALLED", "0", 1); + g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "0", 1); + g_setenv("BT_TEST_PLUGIN_EXIT_CALLED", "0", 1); } static char *get_test_plugin_path(const char *plugin_dir, -- 2.34.1