Closed Bug 1452693 Opened 7 years ago Closed 6 years ago

Add a checker to forbid calls to specific functions

Categories

(Developer Infrastructure :: Source Code Analysis, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1485588

People

(Reporter: Waldo, Unassigned)

References

(Blocks 1 open bug)

Details

Some code in Gecko currently uses the standard C library's isalpha function -- almost certainly to determine whether the character matches [a-zA-Z]. But isalpha is a locale-sensitive function, so it doesn't give consistent results, and people shouldn't be using it. (Plus, as bug 1452619 shows, certain misuses of it can produce bugs for somewhat unrelated reasons.) Code shouldn't be using isalpha, and it should be forbidden to use it in our tree. I would suggest implementing this check such that forbidding a function (surely we want something we can use repeatedly here) is a matter of adding one line to exclude it, or one line plus conditionals to exclude permitted uses. (It's possible that some functions might be permitted to be called only in imported code, for example -- or .)
Here's some more that share the same implementation as isalpha (at least on Windows): Include\10.0.15063.0\ucrt\ctype.h:189: #define _isalpha_l(c, locale) _ischartype_l(c, _ALPHA, locale) Include\10.0.15063.0\ucrt\ctype.h:190: #define _isupper_l(c, locale) _ischartype_l(c, _UPPER, locale) Include\10.0.15063.0\ucrt\ctype.h:191: #define _islower_l(c, locale) _ischartype_l(c, _LOWER, locale) Include\10.0.15063.0\ucrt\ctype.h:192: #define _isdigit_l(c, locale) _ischartype_l(c, _DIGIT, locale) Include\10.0.15063.0\ucrt\ctype.h:193: #define _isxdigit_l(c, locale) _ischartype_l(c, _HEX, locale) Include\10.0.15063.0\ucrt\ctype.h:194: #define _isspace_l(c, locale) _ischartype_l(c, _SPACE, locale) Include\10.0.15063.0\ucrt\ctype.h:195: #define _ispunct_l(c, locale) _ischartype_l(c, _PUNCT, locale) Include\10.0.15063.0\ucrt\ctype.h:196: #define _isblank_l(c, locale) (((c) == '\t') ? _BLANK : _ischartype_l(c, _BLANK, locale)) Include\10.0.15063.0\ucrt\ctype.h:197: #define _isalnum_l(c, locale) _ischartype_l(c, _ALPHA | _DIGIT, locale) Include\10.0.15063.0\ucrt\ctype.h:198: #define _isprint_l(c, locale) _ischartype_l(c, _BLANK | _PUNCT | _ALPHA | _DIGIT, locale) Include\10.0.15063.0\ucrt\ctype.h:199: #define _isgraph_l(c, locale) _ischartype_l(c, _PUNCT | _ALPHA | _DIGIT, locale) Include\10.0.15063.0\ucrt\ctype.h:200: #define _iscntrl_l(c, locale) _ischartype_l(c, _CONTROL, locale)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.