mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Add semantic patch to explicitly cast chars to unsigned for ctype.h
Add a semantic patch to catch all the places where we pass 'char' to the
<ctype.h> family of functions (isalpha() and friends, toupper(),
tolower()). While it generally works because the way how these
functions are constructed in the libc, it's safer to do the explicit
cast.
(cherry picked from commit 5ec65ab5d0
)
This commit is contained in:
105
cocci/ctype.spatch
Normal file
105
cocci/ctype.spatch
Normal file
@@ -0,0 +1,105 @@
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isalnum(T)
|
||||
+ isalnum((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isalpha(T)
|
||||
+ isalpha((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- iscntrl(T)
|
||||
+ iscntrl((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isdigit(T)
|
||||
+ isdigit((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isgraph(T)
|
||||
+ isgraph((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- islower(T)
|
||||
+ islower((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isprint(T)
|
||||
+ isprint((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- ispunct(T)
|
||||
+ ispunct((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isspace(T)
|
||||
+ isspace((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isupper(T)
|
||||
+ isupper((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isxdigit(T)
|
||||
+ isxdigit((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isascii(T)
|
||||
+ isascii((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- isblank(T)
|
||||
+ isblank((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- tolower(T)
|
||||
+ tolower((unsigned char)T)
|
||||
|
||||
@@
|
||||
char T;
|
||||
@@
|
||||
|
||||
- toupper(T)
|
||||
+ toupper((unsigned char)T)
|
||||
|
Reference in New Issue
Block a user