diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index faa8a275e..28c04887b 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -268,6 +268,27 @@ def generate_checked_headers(header_paths): for node in ast.ext if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) ] + # remove std headers functions + functions = [ + f + for f in functions + if f.name + not in ( + "__mempcpy", + "__stpcpy", + "memmem", + "memmove", + "mempcpy", + "memset", + "strcasestr", + "strcat", + "strchrnul", + "strcmp", + "strlcat", + "strlcpy", + "strlen", + ) + ] functions = sorted(functions, key=lambda f: f.name) return_types = { diff --git a/core/iwasm/include/wasm_c_api_checked.h b/core/iwasm/include/wasm_c_api_checked.h index 05a758243..83e73a319 100644 --- a/core/iwasm/include/wasm_c_api_checked.h +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -130,27 +130,6 @@ __memcmpeq_checked(void *__s1, void *__s2, size_t __n) return res; } -static inline Result -__stpcpy_checked(void *__dest, void *__src) -{ - Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: __src - if (__src == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - __stpcpy(__dest, __src); - // Assign return value and error code - res.error_code = 0; - return res; -} - static inline Result __stpncpy_checked(void *__dest, void *__src, size_t __n) { @@ -430,43 +409,6 @@ memcpy_checked(void *__dest, void *__src, size_t __n) return res; } -static inline Result -memmove_checked(void *__dest, void *__src, size_t __n) -{ - Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: __src - if (__src == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - memmove(__dest, __src, __n); - // Assign return value and error code - res.error_code = 0; - return res; -} - -static inline Result -memset_checked(void *__s, int __c, size_t __n) -{ - Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - memset(__s, __c, __n); - // Assign return value and error code - res.error_code = 0; - return res; -} - static inline Result rindex_checked(void *__s, int __c) { @@ -579,27 +521,6 @@ strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) return res; } -static inline Result -strcat_checked(void *__dest, void *__src) -{ - Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: __src - if (__src == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - strcat(__dest, __src); - // Assign return value and error code - res.error_code = 0; - return res; -} - static inline Result strchr_checked(void *__s, int __c) { @@ -616,33 +537,6 @@ strchr_checked(void *__s, int __c) return res; } -static inline Result -strcmp_checked(void *__s1, void *__s2) -{ - Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - int original_result = strcmp(__s1, __s2); - // Assign return value and error code - if (original_result == 0) { - res.error_code = 0; - res.value.int_value = original_result; - } - else { - res.error_code = -2; - } - return res; -} - static inline Result strcoll_checked(void *__s1, void *__s2) { @@ -805,28 +699,6 @@ strerror_r_checked(int __errnum, void *__buf, size_t __buflen) return res; } -static inline Result -strlen_checked(void *__s) -{ - Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - size_t original_result = strlen(__s); - // Assign return value and error code - if (original_result == 0) { - res.error_code = 0; - res.value.size_t_value = original_result; - } - else { - res.error_code = -2; - } - return res; -} - static inline Result strncasecmp_checked(void *__s1, void *__s2, size_t __n) {