From 49cf578b76d573ebee2cf7e4f9b398dc64a13025 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Sat, 8 Nov 2014 09:30:53 +0100 Subject: Fix warnings: ex_cmds2.c: do_source(): Unitialized arg (2): MI. Problem : Uninitialized argument value @ 2485. Uninitialized argument value @ 2507. Diagnostic : Multithreading issues. Rationale : Error can only occur if globals `do_profiling`, `time_fd` are modified while function is executing. Resolution : Use local copy of globals. --- src/nvim/ex_cmds2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 28483f9fdf..1636d62c74 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2405,11 +2405,13 @@ do_source ( // time_fd was successfully opened afterwards. proftime_T rel_time; proftime_T start_time; - if (time_fd != NULL) { + FILE * const l_time_fd = time_fd; + if (l_time_fd != NULL) { time_push(&rel_time, &start_time); } - if (do_profiling == PROF_YES) + const int l_do_profiling = do_profiling; + if (l_do_profiling == PROF_YES) prof_child_enter(&wait_start); /* entering a child now */ /* Don't use local function variables, if called from a function. @@ -2457,7 +2459,7 @@ do_source ( new_script_vars(current_SID); } - if (do_profiling == PROF_YES) { + if (l_do_profiling == PROF_YES) { int forceit; /* Check if we do profiling for this script. */ @@ -2479,7 +2481,7 @@ do_source ( DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT); retval = OK; - if (do_profiling == PROF_YES) { + if (l_do_profiling == PROF_YES) { /* Get "si" again, "script_items" may have been reallocated. */ si = &SCRIPT_ITEM(current_SID); if (si->sn_prof_on) { @@ -2503,7 +2505,7 @@ do_source ( verbose_leave(); } - if (time_fd != NULL) { + if (l_time_fd != NULL) { vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname); time_msg((char *)IObuff, &start_time); time_pop(rel_time); @@ -2519,7 +2521,7 @@ do_source ( current_SID = save_current_SID; restore_funccal(save_funccalp); - if (do_profiling == PROF_YES) + if (l_do_profiling == PROF_YES) prof_child_exit(&wait_start); /* leaving a child now */ fclose(cookie.fp); free(cookie.nextline); -- cgit