]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
trace: Use an array of skipped function names
authorBenjamin Berg <benjamin.berg@intel.com>
Mon, 20 Nov 2023 23:51:48 +0000 (01:51 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 26 Nov 2023 10:14:04 +0000 (12:14 +0200)
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
src/utils/os_unix.c

index 6fa366415174647d92cd2e06ca77e24c95d69a34..bb47d096c5ebce5302e345e93cc7597b71cad97e 100644 (file)
@@ -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;