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)
| 2022 | |
| 2023 | |
| 2024 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
| 2025 | """Checks for calls to thread-unsafe functions. |
| 2026 | |
| 2027 | Much code has been originally written without consideration of |
| 2028 | multi-threading. Also, engineers are relying on their old experience; |
| 2029 | they have learned posix before threading extensions were added. These |
| 2030 | tests guide the engineers to use thread-safe functions (when using |
| 2031 | posix directly). |
| 2032 | |
| 2033 | Args: |
| 2034 | filename: The name of the current file. |
| 2035 | clean_lines: A CleansedLines instance containing the file. |
| 2036 | linenum: The number of the line to check. |
| 2037 | error: The function to call with any errors found. |
| 2038 | """ |
| 2039 | line = clean_lines.elided[linenum] |
| 2040 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
| 2041 | # Additional pattern matching check to confirm that this is the |
| 2042 | # function we are looking for |
| 2043 | if Search(pattern, line): |
| 2044 | error(filename, linenum, 'runtime/threadsafe_fn', 2, |
| 2045 | 'Consider using ' + multithread_safe_func + |
| 2046 | '...) instead of ' + single_thread_func + |
| 2047 | '...) for improved thread safety.') |
| 2048 | |
| 2049 | |
| 2050 | def CheckVlogArguments(filename, clean_lines, linenum, error): |
no test coverage detected