MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CheckPosixThreading

Function CheckPosixThreading

rtpose_wrapper/scripts/cpp_lint.py:1681–1705  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1679
1680
1681def CheckPosixThreading(filename, clean_lines, linenum, error):
1682 """Checks for calls to thread-unsafe functions.
1683
1684 Much code has been originally written without consideration of
1685 multi-threading. Also, engineers are relying on their old experience;
1686 they have learned posix before threading extensions were added. These
1687 tests guide the engineers to use thread-safe functions (when using
1688 posix directly).
1689
1690 Args:
1691 filename: The name of the current file.
1692 clean_lines: A CleansedLines instance containing the file.
1693 linenum: The number of the line to check.
1694 error: The function to call with any errors found.
1695 """
1696 line = clean_lines.elided[linenum]
1697 for single_thread_function, multithread_safe_function in threading_list:
1698 ix = line.find(single_thread_function)
1699 # Comparisons made explicit for clarity -- pylint: disable=g-explicit-bool-comparison
1700 if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and
1701 line[ix - 1] not in ('_', '.', '>'))):
1702 error(filename, linenum, 'runtime/threadsafe_fn', 2,
1703 'Consider using ' + multithread_safe_function +
1704 '...) instead of ' + single_thread_function +
1705 '...) for improved thread safety.')
1706
1707
1708def CheckVlogArguments(filename, clean_lines, linenum, error):

Callers 1

ProcessLineFunction · 0.85

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected