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 th
(filename, clean_lines, linenum, error)
| 2920 | |
| 2921 | |
| 2922 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
| 2923 | """Checks for calls to thread-unsafe functions. |
| 2924 | |
| 2925 | Much code has been originally written without consideration of |
| 2926 | multi-threading. Also, engineers are relying on their old experience; |
| 2927 | they have learned posix before threading extensions were added. These |
| 2928 | tests guide the engineers to use thread-safe functions (when using |
| 2929 | posix directly). |
| 2930 | |
| 2931 | Args: |
| 2932 | filename: The name of the current file. |
| 2933 | clean_lines: A CleansedLines instance containing the file. |
| 2934 | linenum: The number of the line to check. |
| 2935 | error: The function to call with any errors found. |
| 2936 | """ |
| 2937 | line = clean_lines.elided[linenum] |
| 2938 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
| 2939 | # Additional pattern matching check to confirm that this is the |
| 2940 | # function we are looking for |
| 2941 | if re.search(pattern, line): |
| 2942 | error( |
| 2943 | filename, |
| 2944 | linenum, |
| 2945 | "runtime/threadsafe_fn", |
| 2946 | 2, |
| 2947 | "Consider using " |
| 2948 | + multithread_safe_func |
| 2949 | + "...) instead of " |
| 2950 | + single_thread_func |
| 2951 | + "...) for improved thread safety.", |
| 2952 | ) |
| 2953 | |
| 2954 | |
| 2955 | def CheckVlogArguments(filename, clean_lines, linenum, error): |
no test coverage detected
searching dependent graphs…