Checks for calls to thread-unsafe functions. Much code has been originally written without consideration of multi-threading. Also, engineers are relying on their old experience; they have learned posix before threading extensions were added. These tests guide the engineers to use thread-saf
(filename, clean_lines, linenum, error)
| 2122 | |
| 2123 | |
| 2124 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
| 2125 | """Checks for calls to thread-unsafe functions. |
| 2126 | |
| 2127 | Much code has been originally written without consideration of |
| 2128 | multi-threading. Also, engineers are relying on their old experience; |
| 2129 | they have learned posix before threading extensions were added. These |
| 2130 | tests guide the engineers to use thread-safe functions (when using |
| 2131 | posix directly). |
| 2132 | |
| 2133 | Args: |
| 2134 | filename: The name of the current file. |
| 2135 | clean_lines: A CleansedLines instance containing the file. |
| 2136 | linenum: The number of the line to check. |
| 2137 | error: The function to call with any errors found. |
| 2138 | """ |
| 2139 | line = clean_lines.elided[linenum] |
| 2140 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
| 2141 | # Additional pattern matching check to confirm that this is the |
| 2142 | # function we are looking for |
| 2143 | if Search(pattern, line): |
| 2144 | error(filename, linenum, 'runtime/threadsafe_fn', 2, |
| 2145 | 'Consider using ' + multithread_safe_func + |
| 2146 | '...) instead of ' + single_thread_func + |
| 2147 | '...) for improved thread safety.') |
| 2148 | |
| 2149 | |
| 2150 | def CheckVlogArguments(filename, clean_lines, linenum, error): |
no test coverage detected