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)
| 2860 | |
| 2861 | |
| 2862 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
| 2863 | """Checks for calls to thread-unsafe functions. |
| 2864 | |
| 2865 | Much code has been originally written without consideration of |
| 2866 | multi-threading. Also, engineers are relying on their old experience; |
| 2867 | they have learned posix before threading extensions were added. These |
| 2868 | tests guide the engineers to use thread-safe functions (when using |
| 2869 | posix directly). |
| 2870 | |
| 2871 | Args: |
| 2872 | filename: The name of the current file. |
| 2873 | clean_lines: A CleansedLines instance containing the file. |
| 2874 | linenum: The number of the line to check. |
| 2875 | error: The function to call with any errors found. |
| 2876 | """ |
| 2877 | line = clean_lines.elided[linenum] |
| 2878 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
| 2879 | # Additional pattern matching check to confirm that this is the |
| 2880 | # function we are looking for |
| 2881 | if re.search(pattern, line): |
| 2882 | error( |
| 2883 | filename, |
| 2884 | linenum, |
| 2885 | "runtime/threadsafe_fn", |
| 2886 | 2, |
| 2887 | "Consider using " |
| 2888 | + multithread_safe_func |
| 2889 | + "...) instead of " |
| 2890 | + single_thread_func |
| 2891 | + "...) for improved thread safety.", |
| 2892 | ) |
| 2893 | |
| 2894 | |
| 2895 | def CheckVlogArguments(filename, clean_lines, linenum, error): |