<p>I'm refactoring "spaghetti code" C module to work in multitasking (RTOS) environment.</p>

<p>Now, there are very long functions and many unnecessary global variables.</p>

<p>When I try to replace global variables that exists only in one function with locals, I get into dilemma. Every global variable is behave like local "static" - e.g. keep its value even you exit and re-enter to the function.</p>

<p>For multitasking "static" local vars are worst from global. They make the functions non reentered.</p>

<p>There are a way to examine if the function is relay on preserving variable value re-entrancing without tracing all the logical flow?</p>

Please give examples of what you call 'global' and 'local' variables
```
```
int global_c; // can be used by any other file with 'extern int global_c;'

static int static_c; // cannot be seen or used outside of this file.

int foo(...)
{
   int local_c; // cannot be seen or used outside of this function.
}
```
```
If you provide some code samples of what you have and what you changed we could better answer the question.