From 030cd90bd9cc7c79c96759a9be84893ea5a8fa52 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Sun, 11 Nov 2018 10:19:40 -0800 Subject: [PATCH] qcacld-3.0: Rename hdd_is_valid_mac_address() pMacAddr param hdd_is_valid_mac_address() currently takes a parameter named pMacAddr. Per the Linux coding style "mixed-case names are frowned upon" and "so-called Hungarian notation [...] is brain damaged" so rename the parameter to mac_addr to conform to the naming convention. As part of the cleanup relocate the documentation so that the interface is documented, not the implementation. Change-Id: I4abff563bb396a4ffce1356527307ce3bfed8a16 CRs-Fixed: 2347990 --- core/hdd/inc/wlan_hdd_main.h | 18 +++++++++++++++++- core/hdd/src/wlan_hdd_main.c | 27 ++++++--------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 8c7a963679..41d6d771dc 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -2289,7 +2289,23 @@ int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func); int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func); -bool hdd_is_valid_mac_address(const uint8_t *pMacAddr); +/** + * hdd_is_valid_mac_address() - validate MAC address + * @mac_addr: Pointer to the input MAC address + * + * This function validates whether the given MAC address is valid or not + * Expected MAC address is of the format XX:XX:XX:XX:XX:XX + * where X is the hexa decimal digit character and separated by ':' + * This algorithm works even if MAC address is not separated by ':' + * + * This code checks given input string mac contains exactly 12 hexadecimal + * digits and a separator colon : appears in the input string only after + * an even number of hex digits. + * + * Return: true for valid and false for invalid + */ +bool hdd_is_valid_mac_address(const uint8_t *mac_addr); + QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx); bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx); diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index b4e2f21916..169bf2a5a1 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -1987,39 +1987,24 @@ bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) return true; } -/** - * hdd_is_valid_mac_address() - validate MAC address - * @pMacAddr: Pointer to the input MAC address - * - * This function validates whether the given MAC address is valid or not - * Expected MAC address is of the format XX:XX:XX:XX:XX:XX - * where X is the hexa decimal digit character and separated by ':' - * This algorithm works even if MAC address is not separated by ':' - * - * This code checks given input string mac contains exactly 12 hexadecimal - * digits and a separator colon : appears in the input string only after - * an even number of hex digits. - * - * Return: 1 for valid and 0 for invalid - */ -bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) +bool hdd_is_valid_mac_address(const uint8_t *mac_addr) { int xdigit = 0; int separator = 0; - while (*pMacAddr) { - if (isxdigit(*pMacAddr)) { + while (*mac_addr) { + if (isxdigit(*mac_addr)) { xdigit++; - } else if (':' == *pMacAddr) { + } else if (':' == *mac_addr) { if (0 == xdigit || ((xdigit / 2) - 1) != separator) break; ++separator; } else { /* Invalid MAC found */ - return 0; + return false; } - ++pMacAddr; + ++mac_addr; } return xdigit == 12 && (separator == 5 || separator == 0); }