Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst

raw
1 .. title:: clang-tidy - cert-err33-c
2
3 cert-err33-c
4 ============
5
6 Warns on unused function return values. Many of the standard library functions
7 return a value that indicates if the call was successful. Ignoring the returned
8 value can cause unexpected behavior if an error has occurred. The following
9 functions are checked:
10
11 * aligned_alloc()
12 * asctime_s()
13 * at_quick_exit()
14 * atexit()
15 * bsearch()
16 * bsearch_s()
17 * btowc()
18 * c16rtomb()
19 * c32rtomb()
20 * calloc()
21 * clock()
22 * cnd_broadcast()
23 * cnd_init()
24 * cnd_signal()
25 * cnd_timedwait()
26 * cnd_wait()
27 * ctime_s()
28 * fclose()
29 * fflush()
30 * fgetc()
31 * fgetpos()
32 * fgets()
33 * fgetwc()
34 * fopen()
35 * fopen_s()
36 * fprintf()
37 * fprintf_s()
38 * fputc()
39 * fputs()
40 * fputwc()
41 * fputws()
42 * fread()
43 * freopen()
44 * freopen_s()
45 * fscanf()
46 * fscanf_s()
47 * fseek()
48 * fsetpos()
49 * ftell()
50 * fwprintf()
51 * fwprintf_s()
52 * fwrite()
53 * fwscanf()
54 * fwscanf_s()
55 * getc()
56 * getchar()
57 * getenv()
58 * getenv_s()
59 * gets_s()
60 * getwc()
61 * getwchar()
62 * gmtime()
63 * gmtime_s()
64 * localtime()
65 * localtime_s()
66 * malloc()
67 * mbrtoc16()
68 * mbrtoc32()
69 * mbsrtowcs()
70 * mbsrtowcs_s()
71 * mbstowcs()
72 * mbstowcs_s()
73 * memchr()
74 * mktime()
75 * mtx_init()
76 * mtx_lock()
77 * mtx_timedlock()
78 * mtx_trylock()
79 * mtx_unlock()
80 * printf_s()
81 * putc()
82 * putwc()
83 * raise()
84 * realloc()
85 * remove()
86 * rename()
87 * setlocale()
88 * setvbuf()
89 * scanf()
90 * scanf_s()
91 * signal()
92 * snprintf()
93 * snprintf_s()
94 * sprintf()
95 * sprintf_s()
96 * sscanf()
97 * sscanf_s()
98 * strchr()
99 * strerror_s()
100 * strftime()
101 * strpbrk()
102 * strrchr()
103 * strstr()
104 * strtod()
105 * strtof()
106 * strtoimax()
107 * strtok()
108 * strtok_s()
109 * strtol()
110 * strtold()
111 * strtoll()
112 * strtoumax()
113 * strtoul()
114 * strtoull()
115 * strxfrm()
116 * swprintf()
117 * swprintf_s()
118 * swscanf()
119 * swscanf_s()
120 * thrd_create()
121 * thrd_detach()
122 * thrd_join()
123 * thrd_sleep()
124 * time()
125 * timespec_get()
126 * tmpfile()
127 * tmpfile_s()
128 * tmpnam()
129 * tmpnam_s()
130 * tss_create()
131 * tss_get()
132 * tss_set()
133 * ungetc()
134 * ungetwc()
135 * vfprintf()
136 * vfprintf_s()
137 * vfscanf()
138 * vfscanf_s()
139 * vfwprintf()
140 * vfwprintf_s()
141 * vfwscanf()
142 * vfwscanf_s()
143 * vprintf_s()
144 * vscanf()
145 * vscanf_s()
146 * vsnprintf()
147 * vsnprintf_s()
148 * vsprintf()
149 * vsprintf_s()
150 * vsscanf()
151 * vsscanf_s()
152 * vswprintf()
153 * vswprintf_s()
154 * vswscanf()
155 * vswscanf_s()
156 * vwprintf_s()
157 * vwscanf()
158 * vwscanf_s()
159 * wcrtomb()
160 * wcschr()
161 * wcsftime()
162 * wcspbrk()
163 * wcsrchr()
164 * wcsrtombs()
165 * wcsrtombs_s()
166 * wcsstr()
167 * wcstod()
168 * wcstof()
169 * wcstoimax()
170 * wcstok()
171 * wcstok_s()
172 * wcstol()
173 * wcstold()
174 * wcstoll()
175 * wcstombs()
176 * wcstombs_s()
177 * wcstoumax()
178 * wcstoul()
179 * wcstoull()
180 * wcsxfrm()
181 * wctob()
182 * wctrans()
183 * wctype()
184 * wmemchr()
185 * wprintf_s()
186 * wscanf()
187 * wscanf_s()
188
189 This check is an alias of check `bugprone-unused-return-value <../bugprone/unused-return-value.html>`_
190 with a fixed set of functions.
191
192 The check corresponds to a part of CERT C Coding Standard rule `ERR33-C.
193 Detect and handle standard library errors
194 <https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors>`_.
195 The list of checked functions is taken from the rule, with following exception:
196
197 * The check can not differentiate if a function is called with ``NULL``
198 argument. Therefore the following functions are not checked:
199 ``mblen``, ``mbrlen``, ``mbrtowc``, ``mbtowc``, ``wctomb``, ``wctomb_s``