From e55df99ee6281f43de620c6bd46faee2ca0252a2 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 6 Aug 2016 12:38:21 +0300 Subject: [PATCH] Share a single str_starts() implementation No need to define this as a static function in multiple files. Signed-off-by: Jouni Malinen --- hostapd/hostapd_cli.c | 6 ------ src/ap/wps_hostapd.c | 6 ------ src/utils/common.c | 6 ++++++ src/utils/common.h | 2 ++ src/wps/wps_upnp_ssdp.c | 6 ------ wpa_supplicant/wpa_cli.c | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index 70629aa65..376a02572 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -92,12 +92,6 @@ static int get_cmd_arg_num(const char *str, int pos) } -static int str_starts(const char *src, const char *match) -{ - return os_strncmp(src, match, os_strlen(match)) == 0; -} - - static void register_event_handler(struct wpa_ctrl *ctrl) { if (!ctrl_conn) diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index faf38c98d..95b40da0f 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -269,12 +269,6 @@ static void hostapd_wps_enrollee_seen_cb(void *ctx, const u8 *addr, } -static int str_starts(const char *str, const char *start) -{ - return os_strncmp(str, start, os_strlen(start)) == 0; -} - - static void wps_reload_config(void *eloop_data, void *user_ctx) { struct hostapd_iface *iface = eloop_data; diff --git a/src/utils/common.c b/src/utils/common.c index 985646324..68413b2d4 100644 --- a/src/utils/common.c +++ b/src/utils/common.c @@ -1194,3 +1194,9 @@ int ssid_parse(const char *buf, struct wpa_ssid_value *ssid) return ssid->ssid_len ? 0 : -1; } + + +int str_starts(const char *str, const char *start) +{ + return os_strncmp(str, start, os_strlen(start)) == 0; +} diff --git a/src/utils/common.h b/src/utils/common.h index 197e4d1b2..77856774d 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -550,6 +550,8 @@ size_t utf8_unescape(const char *inp, size_t in_size, char *outp, size_t out_size); int is_ctrl_char(char c); +int str_starts(const char *str, const char *start); + /* * gcc 4.4 ends up generating strict-aliasing warnings about some very common diff --git a/src/wps/wps_upnp_ssdp.c b/src/wps/wps_upnp_ssdp.c index 968fc03f9..a685ce4c3 100644 --- a/src/wps/wps_upnp_ssdp.c +++ b/src/wps/wps_upnp_ssdp.c @@ -100,12 +100,6 @@ static int line_length(const char *l) } -static int str_starts(const char *str, const char *start) -{ - return os_strncmp(str, start, os_strlen(start)) == 0; -} - - /*************************************************************************** * Advertisements. * These are multicast to the world to tell them we are here. diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 30f0bafb1..761421812 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -108,12 +108,6 @@ static int get_cmd_arg_num(const char *str, int pos) } -static int str_starts(const char *src, const char *match) -{ - return os_strncmp(src, match, os_strlen(match)) == 0; -} - - static int wpa_cli_show_event(const char *event) { const char *start;