summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2025-10-28 23:13:42 +0100
committerjvoisin2025-10-28 23:13:42 +0100
commit8a43ce98138d363b6595a16b98b6016c5e306191 (patch)
tree2de12f64ed9bb15ef0a224b5085ce0ad4fa6a37e
parent89b628d34b1ef0423df35a72901daa194d7db956 (diff)
Use C90-compliant comments
-rw-r--r--include/fortify-headers.h7
-rw-r--r--include/stdio.h10
-rw-r--r--include/stdlib.h8
-rw-r--r--include/string.h14
-rw-r--r--include/strings.h3
-rw-r--r--include/wchar.h2
6 files changed, 24 insertions, 20 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index 7e84075..b5c8bc0 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -124,11 +124,12 @@
124 124
125#endif /* __has_attribute */ 125#endif /* __has_attribute */
126 126
127// Since we're not allow to include anything. 127/*
128// https://awesomekling.github.io/How-SerenityOS-declares-ssize_t/ 128 Since we're not allow to include anything.
129 https://awesomekling.github.io/How-SerenityOS-declares-ssize_t/
130*/
129#define __fh_size_t __typeof__(sizeof(char)) 131#define __fh_size_t __typeof__(sizeof(char))
130 132
131//TODO(jvoisin) Add a check for overflows
132/* check if pointers are overlapping but not if dst == src, 133/* check if pointers are overlapping but not if dst == src,
133 * since gcc seems to like to generate code that relies on dst == src */ 134 * since gcc seems to like to generate code that relies on dst == src */
134#define __fh_overlap(a, len_a, b, len_b) \ 135#define __fh_overlap(a, len_a, b, len_b) \
diff --git a/include/stdio.h b/include/stdio.h
index 3c22d12..4403af2 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -239,8 +239,8 @@ _FORTIFY_FN(vasprintf) int vasprintf(char **strp, const char *fmt, __builtin_va_
239} 239}
240 240
241 241
242#endif // defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 242#endif /* defined(_GNU_SOURCE) || defined(_BSD_SOURCE) */
243#endif // __clang__ 243#endif /* __clang__ */
244 244
245 245
246#if 0 246#if 0
@@ -260,7 +260,7 @@ _FORTIFY_FN(vasprintf) int vasprintf(char **strp, const char *fmt, __builtin_va_
260 * TODO: add __diagnose_as_builtin 260 * TODO: add __diagnose_as_builtin
261 */ 261 */
262 262
263// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110834 263/* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110834 */
264#pragma GCC diagnostic push 264#pragma GCC diagnostic push
265#pragma GCC diagnostic ignored "-Wformat-nonliteral" 265#pragma GCC diagnostic ignored "-Wformat-nonliteral"
266 266
@@ -287,7 +287,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
287} 287}
288 288
289__fh_format(printf, 2, 3) 289__fh_format(printf, 2, 3)
290//__fh_access(write_only, 1) 290/* __fh_access(write_only, 1) */
291__fh_access(read_only, 2) 291__fh_access(read_only, 2)
292_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) 292_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
293{ 293{
@@ -352,7 +352,7 @@ _FORTIFY_FN(asprintf) int asprintf(char **strp, const char *fmt, ...)
352 return ret; 352 return ret;
353#endif 353#endif
354} 354}
355#endif // __clang__ 355#endif /* __clang__ */
356#endif 356#endif
357 357
358#pragma GCC diagnostic pop 358#pragma GCC diagnostic pop
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c10906..0c4e40c 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -74,7 +74,7 @@ _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
74 __builtin_trap(); 74 __builtin_trap();
75 return __orig_wctomb(__s, __w); 75 return __orig_wctomb(__s, __w);
76} 76}
77#endif // MB_CUR_MAX 77#endif /* MB_CUR_MAX */
78#endif 78#endif
79 79
80#undef qsort 80#undef qsort
@@ -153,7 +153,7 @@ __diagnose_as_builtin(__builtin_realpath, 1, 2)
153#endif 153#endif
154_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) 154_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
155{ 155{
156 // PATH_MAX is defined as 4096 156 /* PATH_MAX is defined as 4096 */
157 if (__r && 4096 > __fh_bos(__r, 2)) { 157 if (__r && 4096 > __fh_bos(__r, 2)) {
158 char __buf[4096], *__ret; 158 char __buf[4096], *__ret;
159 __fh_size_t __l; 159 __fh_size_t __l;
@@ -171,12 +171,12 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
171} 171}
172#endif 172#endif
173 173
174#endif // clang 174#endif /* clang */
175 175
176#ifdef __cplusplus 176#ifdef __cplusplus
177} 177}
178#endif 178#endif
179 179
180#endif // _FORTIFY_SOURCE 180#endif /* _FORTIFY_SOURCE */
181 181
182#endif 182#endif
diff --git a/include/string.h b/include/string.h
index dc7cc19..7a8564a 100644
--- a/include/string.h
+++ b/include/string.h
@@ -213,9 +213,10 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
213#if __has_builtin(__builtin___stpncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK) 213#if __has_builtin(__builtin___stpncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK)
214 return __builtin___stpncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); 214 return __builtin___stpncpy_chk(__d, __s, __n, __fh_bos(__d, 0));
215#else 215#else
216 // If the length strlen(src) is smaller than n, the remaining 216 /* If the length strlen(src) is smaller than n, the remaining
217 // characters in the array pointed to by dest are filled with null 217 * characters in the array pointed to by dest are filled with null
218 // bytes ('\0') 218 * bytes ('\0')
219 */
219 __fh_size_t __b = __fh_bos(__d, 0); 220 __fh_size_t __b = __fh_bos(__d, 0);
220 if (__n > __b) 221 if (__n > __b)
221 __builtin_trap(); 222 __builtin_trap();
@@ -292,7 +293,7 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
292#if __has_builtin(__builtin___strncat_chk) && defined(FORTIFY_USE_NATIVE_CHK) 293#if __has_builtin(__builtin___strncat_chk) && defined(FORTIFY_USE_NATIVE_CHK)
293 return __builtin___strncat_chk(__d, __s, __n, __fh_bos(__d, 0)); 294 return __builtin___strncat_chk(__d, __s, __n, __fh_bos(__d, 0));
294#else 295#else
295#if 0 // strlen(__s) isn't guaranteed to be valid. 296#if 0 /* strlen(__s) isn't guaranteed to be valid. */
296 __fh_size_t __b = __fh_bos(__d, 0); 297 __fh_size_t __b = __fh_bos(__d, 0);
297 298
298 if (__n > __b) { 299 if (__n > __b) {
@@ -319,8 +320,9 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
319#if __has_builtin(__builtin___strncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK) 320#if __has_builtin(__builtin___strncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK)
320 return __builtin___strncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); 321 return __builtin___strncpy_chk(__d, __s, __n, __fh_bos(__d, 0));
321#else 322#else
322 // If the length of src is less than n, strncpy() writes additional 323 /* If the length of src is less than n, strncpy() writes additional
323 // null bytes to dest to ensure that a total of n bytes are written. 324 * null bytes to dest to ensure that a total of n bytes are written.
325 */
324 __fh_size_t __b = __fh_bos(__d, 0); 326 __fh_size_t __b = __fh_bos(__d, 0);
325 if (__n > __b) 327 if (__n > __b)
326 __builtin_trap(); 328 __builtin_trap();
diff --git a/include/strings.h b/include/strings.h
index 511acca..b1c5c77 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -34,7 +34,8 @@ extern "C" {
34__fh_access(write_only, 2, 3) 34__fh_access(write_only, 2, 3)
35__fh_access(read_only, 1, 3) 35__fh_access(read_only, 1, 3)
36#if __has_builtin(__builtin_bcopy) && !defined(__clang__) 36#if __has_builtin(__builtin_bcopy) && !defined(__clang__)
37// parameter 1 of function '__orig_bcopy' has type 'const void *', but parameter 1 of function '__builtin_bcopy' has type 'void *' 37/* parameter 1 of function '__orig_bcopy' has type 'const void, but
38 * parameter 1 of function '__builtin_bcopy' has type 'void *' */
38__diagnose_as_builtin(__builtin_bcopy, 1, 2, 3) 39__diagnose_as_builtin(__builtin_bcopy, 1, 2, 3)
39#endif 40#endif
40_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s, 41_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
diff --git a/include/wchar.h b/include/wchar.h
index 792fad6..ff635eb 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -105,7 +105,7 @@ __diagnose_as_builtin(__builtin_wcrtomb, 1, 2, 3)
105#endif 105#endif
106_FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) 106_FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st)
107{ 107{
108 // In glibc, MB_LEN_MAX is typically 16 (6 in glibc versions earlier than 2.2) 108 /* In glibc, MB_LEN_MAX is typically 16 (6 in glibc versions earlier than 2.2) */
109 if (__s && 16 > __fh_bos(__s, 2)) { 109 if (__s && 16 > __fh_bos(__s, 2)) {
110 char __buf[16]; 110 char __buf[16];
111 __fh_size_t __r; 111 __fh_size_t __r;