From: Benjamin Berg Date: Mon, 20 Nov 2023 23:51:48 +0000 (+0200) Subject: trace: Use an array of skipped function names X-Git-Tag: hostap_2_11~746 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d901dc7e797bea48cc01c0161a8d0a5ca6734b0;p=thirdparty%2Fhostap.git trace: Use an array of skipped function names Signed-off-by: Benjamin Berg --- diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index 6fa366415..bb47d096c 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -545,8 +545,12 @@ static unsigned int wpa_trace_fail_after; static int testing_fail_alloc(void) { + const char *ignore_list[] = { + __func__, "os_malloc", "os_zalloc", "os_calloc", "os_realloc", + "os_realloc_array", "os_strdup", "os_memdup" + }; const char *func[WPA_TRACE_LEN]; - size_t i, res, len; + size_t i, j, res, len; char *pos, *next; int match; @@ -555,22 +559,12 @@ static int testing_fail_alloc(void) res = wpa_trace_calling_func(func, WPA_TRACE_LEN); i = 0; - if (i < res && os_strcmp(func[i], __func__) == 0) - i++; - if (i < res && os_strcmp(func[i], "os_malloc") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_zalloc") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_calloc") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_realloc") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_realloc_array") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_strdup") == 0) - i++; - if (i < res && os_strcmp(func[i], "os_memdup") == 0) - i++; + + /* Skip this function as well as allocation helpers */ + for (j = 0; j < ARRAY_SIZE(ignore_list) && i < res; j++) { + if (os_strcmp(func[i], ignore_list[j]) == 0) + i++; + } pos = wpa_trace_fail_func;