From 8a43ce98138d363b6595a16b98b6016c5e306191 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 28 Oct 2025 23:13:42 +0100 Subject: Use C90-compliant comments --- include/fortify-headers.h | 7 ++++--- include/stdio.h | 10 +++++----- include/stdlib.h | 8 ++++---- include/string.h | 14 ++++++++------ include/strings.h | 3 ++- include/wchar.h | 2 +- 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 @@ #endif /* __has_attribute */ -// Since we're not allow to include anything. -// https://awesomekling.github.io/How-SerenityOS-declares-ssize_t/ +/* + Since we're not allow to include anything. + https://awesomekling.github.io/How-SerenityOS-declares-ssize_t/ +*/ #define __fh_size_t __typeof__(sizeof(char)) -//TODO(jvoisin) Add a check for overflows /* check if pointers are overlapping but not if dst == src, * since gcc seems to like to generate code that relies on dst == src */ #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_ } -#endif // defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#endif // __clang__ +#endif /* defined(_GNU_SOURCE) || defined(_BSD_SOURCE) */ +#endif /* __clang__ */ #if 0 @@ -260,7 +260,7 @@ _FORTIFY_FN(vasprintf) int vasprintf(char **strp, const char *fmt, __builtin_va_ * TODO: add __diagnose_as_builtin */ -// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110834 +/* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110834 */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" @@ -287,7 +287,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, } __fh_format(printf, 2, 3) -//__fh_access(write_only, 1) +/* __fh_access(write_only, 1) */ __fh_access(read_only, 2) _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) { @@ -352,7 +352,7 @@ _FORTIFY_FN(asprintf) int asprintf(char **strp, const char *fmt, ...) return ret; #endif } -#endif // __clang__ +#endif /* __clang__ */ #endif #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) __builtin_trap(); return __orig_wctomb(__s, __w); } -#endif // MB_CUR_MAX +#endif /* MB_CUR_MAX */ #endif #undef qsort @@ -153,7 +153,7 @@ __diagnose_as_builtin(__builtin_realpath, 1, 2) #endif _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) { - // PATH_MAX is defined as 4096 + /* PATH_MAX is defined as 4096 */ if (__r && 4096 > __fh_bos(__r, 2)) { char __buf[4096], *__ret; __fh_size_t __l; @@ -171,12 +171,12 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) } #endif -#endif // clang +#endif /* clang */ #ifdef __cplusplus } #endif -#endif // _FORTIFY_SOURCE +#endif /* _FORTIFY_SOURCE */ #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, #if __has_builtin(__builtin___stpncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK) return __builtin___stpncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); #else - // If the length strlen(src) is smaller than n, the remaining - // characters in the array pointed to by dest are filled with null - // bytes ('\0') + /* If the length strlen(src) is smaller than n, the remaining + * characters in the array pointed to by dest are filled with null + * bytes ('\0') + */ __fh_size_t __b = __fh_bos(__d, 0); if (__n > __b) __builtin_trap(); @@ -292,7 +293,7 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, #if __has_builtin(__builtin___strncat_chk) && defined(FORTIFY_USE_NATIVE_CHK) return __builtin___strncat_chk(__d, __s, __n, __fh_bos(__d, 0)); #else -#if 0 // strlen(__s) isn't guaranteed to be valid. +#if 0 /* strlen(__s) isn't guaranteed to be valid. */ __fh_size_t __b = __fh_bos(__d, 0); if (__n > __b) { @@ -319,8 +320,9 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, #if __has_builtin(__builtin___strncpy_chk) && defined(FORTIFY_USE_NATIVE_CHK) return __builtin___strncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); #else - // If the length of src is less than n, strncpy() writes additional - // null bytes to dest to ensure that a total of n bytes are written. + /* If the length of src is less than n, strncpy() writes additional + * null bytes to dest to ensure that a total of n bytes are written. + */ __fh_size_t __b = __fh_bos(__d, 0); if (__n > __b) __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" { __fh_access(write_only, 2, 3) __fh_access(read_only, 1, 3) #if __has_builtin(__builtin_bcopy) && !defined(__clang__) -// parameter 1 of function '__orig_bcopy' has type 'const void *', but parameter 1 of function '__builtin_bcopy' has type 'void *' +/* parameter 1 of function '__orig_bcopy' has type 'const void, but + * parameter 1 of function '__builtin_bcopy' has type 'void *' */ __diagnose_as_builtin(__builtin_bcopy, 1, 2, 3) #endif _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) #endif _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) { - // In glibc, MB_LEN_MAX is typically 16 (6 in glibc versions earlier than 2.2) + /* In glibc, MB_LEN_MAX is typically 16 (6 in glibc versions earlier than 2.2) */ if (__s && 16 > __fh_bos(__s, 2)) { char __buf[16]; __fh_size_t __r; -- cgit v1.3