From b563452dc6fd378612c0a54d0f7c5a46fe5fb5ab Mon Sep 17 00:00:00 2001 From: yiyajun Date: Sat, 26 Nov 2022 08:38:21 +0000 Subject: [PATCH] update wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp. Signed-off-by: yiyajun --- .../wificdevice_fuzzer/wificdevice_fuzzer.cpp | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp index 8eb23f726..4e4835090 100755 --- a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp +++ b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp @@ -19,55 +19,55 @@ #include "../../../../../../interfaces/kits/c/wifi_device.h" -void EnableWifiTest() +static void EnableWifiTest() { EnableWifi(); } -void DisableWifiTest() +static void DisableWifiTest() { DisableWifi(); } -void ScanTest() +static void ScanTest() { Scan(); } -void DisconnectTest() +static void DisconnectTest() { Disconnect(); } -void RemoveDeviceTest(const uint8_t* data, size_t size) +static void RemoveDeviceTest(const uint8_t* data, size_t size) { - if (size <= 0) { + if (size == 0) { return; } int networkId = static_cast(data[0]); RemoveDevice(networkId); } -void DisableDeviceConfigTest(const uint8_t* data, size_t size) +static void DisableDeviceConfigTest(const uint8_t* data, size_t size) { - if (size <= 0) { + if (size == 0) { return; } int networkId = static_cast(data[0]); DisableDeviceConfig(networkId); } -void EnableDeviceConfigTest(const uint8_t* data, size_t size) +static void EnableDeviceConfigTest(const uint8_t* data, size_t size) { - if (size <= 0) { + if (size == 0) { return; } int networkId = static_cast(data[0]); EnableDeviceConfig(networkId); } -void ConnectToTest(const uint8_t* data, size_t size) +static void ConnectToTest(const uint8_t* data, size_t size) { - if (size <= 0) { + if (size == 0) { return; } int networkId = static_cast(data[0]); ConnectTo(networkId); } -void AddDeviceConfigTest(const uint8_t* data, size_t size) +static void AddDeviceConfigTest(const uint8_t* data, size_t size) { int index = 0; WifiDeviceConfig config; @@ -86,19 +86,13 @@ void AddDeviceConfigTest(const uint8_t* data, size_t size) config.freq = static_cast(data[index++]); config.wapiPskType = static_cast(data[index++]); config.isHiddenSsid = static_cast(data[index++]); - IpType ipType = STATIC_IP; - if (ipType % 2 == 1) { - ipType = DHCP; - } else if (ipType % 2 == 0) { - ipType = UNKNOWN; - } + config.ipType = static_cast(static_cast(data[index++]) % TWO); } int result = static_cast(data[index++]); AddDeviceConfig(&config, &result); } -void AdvanceScanTest(const uint8_t* data, size_t size) +static void AdvanceScanTest(const uint8_t* data, size_t size) { - int index = 0; WifiScanParams params; if (size >= sizeof(WifiScanParams)) { if (memcpy_s(params.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { @@ -107,6 +101,7 @@ void AdvanceScanTest(const uint8_t* data, size_t size) if (memcpy_s(params.bssid, WIFI_MAC_LEN, data, WIFI_MAC_LEN - 1) != EOK) { return; } + int index = 0; params.scanType = WIFI_FREQ_SCAN; params.freqs = static_cast(data[index++]); params.band = static_cast(data[index++]); @@ -114,12 +109,12 @@ void AdvanceScanTest(const uint8_t* data, size_t size) } AdvanceScan(¶ms); } -void GetSignalLevelTest(const uint8_t* data, size_t size) +static void GetSignalLevelTest(const uint8_t* data, size_t size) { int rssi = 0; int band = 0; - int index = 0; - if (size >= 2) { + if (size >= TWO) { + int index = 0; rssi = static_cast(data[index++]); band = static_cast(data[index++]); }