MCPcopy Create free account
hub / github.com/SIPp/sipp / CheckPosixThreading

Function CheckPosixThreading

cpplint.py:1302–1326  ·  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

1300
1301
1302def CheckPosixThreading(filename, clean_lines, linenum, error):
1303 """Checks for calls to thread-unsafe functions.
1304
1305 Much code has been originally written without consideration of
1306 multi-threading. Also, engineers are relying on their old experience;
1307 they have learned posix before threading extensions were added. These
1308 tests guide the engineers to use thread-safe functions (when using
1309 posix directly).
1310
1311 Args:
1312 filename: The name of the current file.
1313 clean_lines: A CleansedLines instance containing the file.
1314 linenum: The number of the line to check.
1315 error: The function to call with any errors found.
1316 """
1317 line = clean_lines.elided[linenum]
1318 for single_thread_function, multithread_safe_function in threading_list:
1319 ix = line.find(single_thread_function)
1320 # Comparisons made explicit for clarity -- pylint: disable-msg=C6403
1321 if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and
1322 line[ix - 1] not in ('_', '.', '>'))):
1323 error(filename, linenum, 'runtime/threadsafe_fn', 2,
1324 'Consider using ' + multithread_safe_function +
1325 '...) instead of ' + single_thread_function +
1326 '...) for improved thread safety.')
1327
1328
1329# Matches invalid increment: *count++, which moves pointer instead of

Callers 1

ProcessLineFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected