@@ 2227-2250 (lines=24) @@ | ||
2224 | ) |
|
2225 | ||
2226 | ||
2227 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
|
2228 | """Checks for calls to thread-unsafe functions. |
|
2229 | ||
2230 | Much code has been originally written without consideration of |
|
2231 | multi-threading. Also, engineers are relying on their old experience; |
|
2232 | they have learned posix before threading extensions were added. These |
|
2233 | tests guide the engineers to use thread-safe functions (when using |
|
2234 | posix directly). |
|
2235 | ||
2236 | Args: |
|
2237 | filename: The name of the current file. |
|
2238 | clean_lines: A CleansedLines instance containing the file. |
|
2239 | linenum: The number of the line to check. |
|
2240 | error: The function to call with any errors found. |
|
2241 | """ |
|
2242 | line = clean_lines.elided[linenum] |
|
2243 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
|
2244 | # Additional pattern matching check to confirm that this is the |
|
2245 | # function we are looking for |
|
2246 | if Search(pattern, line): |
|
2247 | error(filename, linenum, 'runtime/threadsafe_fn', 2, |
|
2248 | 'Consider using ' + multithread_safe_func + |
|
2249 | '...) instead of ' + single_thread_func + |
|
2250 | '...) for improved thread safety.') |
|
2251 | ||
2252 | ||
2253 | def CheckVlogArguments(filename, clean_lines, linenum, error): |
@@ 2227-2250 (lines=24) @@ | ||
2224 | ) |
|
2225 | ||
2226 | ||
2227 | def CheckPosixThreading(filename, clean_lines, linenum, error): |
|
2228 | """Checks for calls to thread-unsafe functions. |
|
2229 | ||
2230 | Much code has been originally written without consideration of |
|
2231 | multi-threading. Also, engineers are relying on their old experience; |
|
2232 | they have learned posix before threading extensions were added. These |
|
2233 | tests guide the engineers to use thread-safe functions (when using |
|
2234 | posix directly). |
|
2235 | ||
2236 | Args: |
|
2237 | filename: The name of the current file. |
|
2238 | clean_lines: A CleansedLines instance containing the file. |
|
2239 | linenum: The number of the line to check. |
|
2240 | error: The function to call with any errors found. |
|
2241 | """ |
|
2242 | line = clean_lines.elided[linenum] |
|
2243 | for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: |
|
2244 | # Additional pattern matching check to confirm that this is the |
|
2245 | # function we are looking for |
|
2246 | if Search(pattern, line): |
|
2247 | error(filename, linenum, 'runtime/threadsafe_fn', 2, |
|
2248 | 'Consider using ' + multithread_safe_func + |
|
2249 | '...) instead of ' + single_thread_func + |
|
2250 | '...) for improved thread safety.') |
|
2251 | ||
2252 | ||
2253 | def CheckVlogArguments(filename, clean_lines, linenum, error): |