From 50a17a76e11bc30f01a67d353146aeb3e47baf4a Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 23 Jun 2016 18:19:00 +0300 Subject: [PATCH] tests: Declare module test functions in a header file This gets rid of number of warnings from sparse. Signed-off-by: Jouni Malinen --- hostapd/ctrl_iface.c | 2 +- hostapd/hapd_module_tests.c | 1 + src/common/common_module_tests.c | 1 + src/crypto/crypto_module_tests.c | 1 + src/utils/module_tests.h | 20 ++++++++++++++++++++ src/utils/utils_module_tests.c | 1 + src/wps/wps_module_tests.c | 1 + wpa_supplicant/ctrl_iface.c | 2 +- wpa_supplicant/wpas_module_tests.c | 29 +++++++++-------------------- 9 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 src/utils/module_tests.h diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index a6e9e9b76..db9e0b065 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -25,6 +25,7 @@ #include "utils/common.h" #include "utils/eloop.h" +#include "utils/module_tests.h" #include "common/version.h" #include "common/ieee802_11_defs.h" #include "common/ctrl_iface_common.h" @@ -3339,7 +3340,6 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx, reply_len = -1; #ifdef CONFIG_MODULE_TESTS } else if (os_strcmp(buf, "MODULE_TESTS") == 0) { - int hapd_module_tests(void); if (hapd_module_tests() < 0) reply_len = -1; #endif /* CONFIG_MODULE_TESTS */ diff --git a/hostapd/hapd_module_tests.c b/hostapd/hapd_module_tests.c index f7887ebfb..a5016f22b 100644 --- a/hostapd/hapd_module_tests.c +++ b/hostapd/hapd_module_tests.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/module_tests.h" int hapd_module_tests(void) { diff --git a/src/common/common_module_tests.c b/src/common/common_module_tests.c index d69448bd3..e0769c08e 100644 --- a/src/common/common_module_tests.c +++ b/src/common/common_module_tests.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/module_tests.h" #include "ieee802_11_common.h" #include "ieee802_11_defs.h" #include "gas.h" diff --git a/src/crypto/crypto_module_tests.c b/src/crypto/crypto_module_tests.c index 7bae76162..ffd23942e 100644 --- a/src/crypto/crypto_module_tests.c +++ b/src/crypto/crypto_module_tests.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/module_tests.h" #include "crypto/aes_siv.h" #include "crypto/aes_wrap.h" #include "crypto/aes.h" diff --git a/src/utils/module_tests.h b/src/utils/module_tests.h new file mode 100644 index 000000000..3bfe4ad02 --- /dev/null +++ b/src/utils/module_tests.h @@ -0,0 +1,20 @@ +/* + * Module tests + * Copyright (c) 2014-2015, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef MODULE_TESTS_H +#define MODULE_TESTS_H + +int wpas_module_tests(void); +int hapd_module_tests(void); + +int utils_module_tests(void); +int wps_module_tests(void); +int common_module_tests(void); +int crypto_module_tests(void); + +#endif /* MODULE_TESTS_H */ diff --git a/src/utils/utils_module_tests.c b/src/utils/utils_module_tests.c index 41511b999..abdb79c98 100644 --- a/src/utils/utils_module_tests.c +++ b/src/utils/utils_module_tests.c @@ -16,6 +16,7 @@ #include "utils/base64.h" #include "utils/ip_addr.h" #include "utils/eloop.h" +#include "utils/module_tests.h" struct printf_test_data { diff --git a/src/wps/wps_module_tests.c b/src/wps/wps_module_tests.c index 9c945b156..23bed4b36 100644 --- a/src/wps/wps_module_tests.c +++ b/src/wps/wps_module_tests.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/module_tests.h" #include "wps_attr_parse.h" struct wps_attr_parse_test { diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index b8e48e25b..e75323da8 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -15,6 +15,7 @@ #include "utils/common.h" #include "utils/eloop.h" #include "utils/uuid.h" +#include "utils/module_tests.h" #include "common/version.h" #include "common/ieee802_11_defs.h" #include "common/ieee802_11_common.h" @@ -10021,7 +10022,6 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global, reply_size); #ifdef CONFIG_MODULE_TESTS } else if (os_strcmp(buf, "MODULE_TESTS") == 0) { - int wpas_module_tests(void); if (wpas_module_tests() < 0) reply_len = -1; #endif /* CONFIG_MODULE_TESTS */ diff --git a/wpa_supplicant/wpas_module_tests.c b/wpa_supplicant/wpas_module_tests.c index 6af1678a4..4e37591be 100644 --- a/wpa_supplicant/wpas_module_tests.c +++ b/wpa_supplicant/wpas_module_tests.c @@ -9,6 +9,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/module_tests.h" #include "wpa_supplicant_i.h" #include "blacklist.h" @@ -79,30 +80,18 @@ int wpas_module_tests(void) ret = -1; #ifdef CONFIG_WPS - { - int wps_module_tests(void); - if (wps_module_tests() < 0) - ret = -1; - } + if (wps_module_tests() < 0) + ret = -1; #endif /* CONFIG_WPS */ - { - int utils_module_tests(void); - if (utils_module_tests() < 0) - ret = -1; - } + if (utils_module_tests() < 0) + ret = -1; - { - int common_module_tests(void); - if (common_module_tests() < 0) - ret = -1; - } + if (common_module_tests() < 0) + ret = -1; - { - int crypto_module_tests(void); - if (crypto_module_tests() < 0) - ret = -1; - } + if (crypto_module_tests() < 0) + ret = -1; return ret; }