[cpplint] modify unsafe thread function list

Modified to detect as unsafe thread function that following defined.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01
This commit is contained in:
Tadaki Sakai 2019-04-15 02:14:20 +09:00
parent 91d6e367e3
commit 7004937c38

85
cpplint/cpplint.py vendored
View File

@ -2101,18 +2101,99 @@ def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error):
_UNSAFE_FUNC_PREFIX = r'(?:[-+*/=%^&|(<]\s*|>\s+)'
_THREADING_LIST = (
('asctime(', 'asctime_r(', _UNSAFE_FUNC_PREFIX + r'asctime\([^)]+\)'),
('basename(', 'basename_r(', _UNSAFE_FUNC_PREFIX + r'basename\([^)]+\)'),
('catgets(', 'catgets_r(', _UNSAFE_FUNC_PREFIX + r'catgets\([^)]+\)'),
('crypt(', 'crypt_r(', _UNSAFE_FUNC_PREFIX + r'crypt\([^)]+\)'),
('ctime(', 'ctime_r(', _UNSAFE_FUNC_PREFIX + r'ctime\([^)]+\)'),
('dbm_clearerr(', 'dbm_clearerr_r(',
_UNSAFE_FUNC_PREFIX + r'dbm_clearerr\([^)]+\)'),
('dbm_close(', 'dbm_close_r(', _UNSAFE_FUNC_PREFIX + r'dbm_close\([^)]+\)'),
('dbm_delete(', 'dbm_delete_r(',
_UNSAFE_FUNC_PREFIX + r'dbm_delete\([^)]+\)'),
('dbm_error(', 'dbm_error_r(', _UNSAFE_FUNC_PREFIX + r'dbm_error\([^)]+\)'),
('dbm_fetch(', 'dbm_fetch_r(', _UNSAFE_FUNC_PREFIX + r'dbm_fetch\([^)]+\)'),
('dbm_firstkey(', 'dbm_firstkey_r(',
_UNSAFE_FUNC_PREFIX + r'dbm_firstkey\([^)]+\)'),
('dbm_nextkey(', 'dbm_nextkey_r(',
_UNSAFE_FUNC_PREFIX + r'dbm_nextkey\([^)]+\)'),
('dbm_open(', 'dbm_open_r(', _UNSAFE_FUNC_PREFIX + r'dbm_open\([^)]+\)'),
('dbm_store(', 'dbm_store_r(', _UNSAFE_FUNC_PREFIX + r'dbm_store\([^)]+\)'),
('dirname(', 'dirname_r(', _UNSAFE_FUNC_PREFIX + r'dirname\([^)]+\)'),
('dlerror(', 'dlerror_r(', _UNSAFE_FUNC_PREFIX + r'dlerror\(\)'),
('drand48(', 'drand48_r(', _UNSAFE_FUNC_PREFIX + r'drand48\(\)'),
('encrypt(', 'encrypt_r(', _UNSAFE_FUNC_PREFIX + r'encrypt\([^)]+\)'),
('endgrent(', 'endgrent_r(', _UNSAFE_FUNC_PREFIX + r'endgrent\(\)'),
('endpwent(', 'endpwent_r(', _UNSAFE_FUNC_PREFIX + r'endpwent\(\)'),
('endutxent(', 'endutxent_r(', _UNSAFE_FUNC_PREFIX + r'endutxent\(\)'),
('ftw(', 'ftw_r(', _UNSAFE_FUNC_PREFIX + r'ftw\([^)]+\)'),
('getdate(', 'getdate_r(', _UNSAFE_FUNC_PREFIX + r'getdate\([^)]+\)'),
('getenv(', 'getenv_r(', _UNSAFE_FUNC_PREFIX + r'getenv\([^)]+\)'),
('getgrent(', 'getgrent_r(', _UNSAFE_FUNC_PREFIX + r'getgrent\(\)'),
('getgrgid(', 'getgrgid_r(', _UNSAFE_FUNC_PREFIX + r'getgrgid\([^)]+\)'),
('getgrnam(', 'getgrnam_r(', _UNSAFE_FUNC_PREFIX + r'getgrnam\([^)]+\)'),
('gethostent(', 'gethostent_r(', _UNSAFE_FUNC_PREFIX + r'gethostent\(\)'),
('getlogin(', 'getlogin_r(', _UNSAFE_FUNC_PREFIX + r'getlogin\(\)'),
('getnetbyaddr(', 'getnetbyaddr_r(',
_UNSAFE_FUNC_PREFIX + r'getnetbyaddr\([^)]+\)'),
('getnetbyname(', 'getnetbyname_r(',
_UNSAFE_FUNC_PREFIX + r'getnetbyname\([^)]+\)'),
('getnetent(', 'getnetent_r(', _UNSAFE_FUNC_PREFIX + r'getnetent\(\)'),
('getopt(', 'getopt_r(', _UNSAFE_FUNC_PREFIX + r'getopt\([^)]+\)'),
('getprotobyname(', 'getprotobyname_r(',
_UNSAFE_FUNC_PREFIX + r'getprotobyname\([^)]+\)'),
('getprotobynumber(', 'getprotobynumber_r(',
_UNSAFE_FUNC_PREFIX + r'getprotobynumber\([^)]+\)'),
('getprotoent(', 'getprotoent_r(',
_UNSAFE_FUNC_PREFIX + r'getprotoent\(\)'),
('getpwent(', 'getpwent_r(', _UNSAFE_FUNC_PREFIX + r'getpwent\(\)'),
('getpwnam(', 'getpwnam_r(', _UNSAFE_FUNC_PREFIX + r'getpwnam\([^)]+\)'),
('getpwuid(', 'getpwuid_r(', _UNSAFE_FUNC_PREFIX + r'getpwuid\([^)]+\)'),
('getservbyname(', 'getservbyname_r(',
_UNSAFE_FUNC_PREFIX + r'getservbyname\([^)]+\)'),
('getservbyport(', 'getservbyport_r(',
_UNSAFE_FUNC_PREFIX + r'getservbyport\([^)]+\)'),
('getservent(', 'getservent_r(', _UNSAFE_FUNC_PREFIX + r'getservent\(\)'),
('getutxent(', 'getutxent_r(', _UNSAFE_FUNC_PREFIX + r'getutxent\(\)'),
('getutxid(', 'getutxid_r(', _UNSAFE_FUNC_PREFIX + r'getutxid\([^)]+\)'),
('getutxline(', 'getutxline_r(',
_UNSAFE_FUNC_PREFIX + r'getutxline\([^)]+\)'),
('gmtime(', 'gmtime_r(', _UNSAFE_FUNC_PREFIX + r'gmtime\([^)]+\)'),
('hcreate(', 'hcreate_r(', _UNSAFE_FUNC_PREFIX + r'hcreate\([^)]+\)'),
('hdestroy(', 'hdestroy_r(', _UNSAFE_FUNC_PREFIX + r'hdestroy\(\)'),
('hsearch(', 'hsearch_r(', _UNSAFE_FUNC_PREFIX + r'hsearch\([^)]+\)'),
('inet_ntoa(', 'inet_ntoa_r(', _UNSAFE_FUNC_PREFIX + r'inet_ntoa\([^)]+\)'),
('l64a(', 'l64a_r(', _UNSAFE_FUNC_PREFIX + r'l64a\([^)]+\)'),
('lgamma(', 'lgamma_r(', _UNSAFE_FUNC_PREFIX + r'lgamma\([^)]+\)'),
('lgammaf(', 'lgammaf_r(', _UNSAFE_FUNC_PREFIX + r'lgammaf\([^)]+\)'),
('lgammal(', 'lgammal_r(', _UNSAFE_FUNC_PREFIX + r'lgammal\([^)]+\)'),
('localeconv(', 'localeconv_r(', _UNSAFE_FUNC_PREFIX + r'localeconv\(\)'),
('localtime(', 'localtime_r(', _UNSAFE_FUNC_PREFIX + r'localtime\([^)]+\)'),
('lrand48(', 'lrand48_r(', _UNSAFE_FUNC_PREFIX + r'lrand48\(\)'),
('mblen(', 'mblen_r(', _UNSAFE_FUNC_PREFIX + r'mblen\([^)]+\)'),
('mbtowc(', 'mbtowc_r(', _UNSAFE_FUNC_PREFIX + r'mbtowc\([^)]+\)'),
('mrand48(', 'mrand48_r(', _UNSAFE_FUNC_PREFIX + r'mrand48\(\)'),
('nftw(', 'nftw_r(', _UNSAFE_FUNC_PREFIX + r'nftw\([^)]+\)'),
('nl_langinfo(', 'nl_langinfo_r(',
_UNSAFE_FUNC_PREFIX + r'nl_langinfo\([^)]+\)'),
('ptsname(', 'ptsname_r(', _UNSAFE_FUNC_PREFIX + r'ptsname\([^)]+\)'),
('putenv(', 'putenv_r(', _UNSAFE_FUNC_PREFIX + r'putenv\([^)]+\)'),
('pututxline(', 'pututxline_r(',
_UNSAFE_FUNC_PREFIX + r'pututxline\([^)]+\)'),
('rand(', 'rand_r(', _UNSAFE_FUNC_PREFIX + r'rand\(\)'),
('strtok(', 'strtok_r(',
_UNSAFE_FUNC_PREFIX + r'strtok\([^)]+\)'),
('readdir(', 'readdir_r(', _UNSAFE_FUNC_PREFIX + r'readdir\([^)]+\)'),
('setenv(', 'setenv_r(', _UNSAFE_FUNC_PREFIX + r'setenv\([^)]+\)'),
('setgrent(', 'setgrent_r(', _UNSAFE_FUNC_PREFIX + r'setgrent\(\)'),
('setkey(', 'setkey_r(', _UNSAFE_FUNC_PREFIX + r'setkey\([^)]+\)'),
('setlocale(', 'setlocale_r(', _UNSAFE_FUNC_PREFIX + r'setlocale\([^)]+\)'),
('setpwent(', 'setpwent_r(', _UNSAFE_FUNC_PREFIX + r'setpwent\(\)'),
('setutxent(', 'setutxent_r(', _UNSAFE_FUNC_PREFIX + r'setutxent\(\)'),
('strerror(', 'strerror_r(', _UNSAFE_FUNC_PREFIX + r'strerror\([^)]+\)'),
('strsignal(', 'strsignal_r(', _UNSAFE_FUNC_PREFIX + r'strsignal\([^)]+\)'),
('strtok(', 'strtok_r(', _UNSAFE_FUNC_PREFIX + r'strtok\([^)]+\)'),
('system(', 'system_r(', _UNSAFE_FUNC_PREFIX + r'system\([^)]+\)'),
('ttyname(', 'ttyname_r(', _UNSAFE_FUNC_PREFIX + r'ttyname\([^)]+\)'),
('unsetenv(', 'unsetenv_r(', _UNSAFE_FUNC_PREFIX + r'unsetenv\([^)]+\)'),
('wctomb(', 'wctomb_r(', _UNSAFE_FUNC_PREFIX + r'wctomb\([^)]+\)'),
)