From dd67a103f5f126b4b9ff8423a4ef7bc9f3210a16 Mon Sep 17 00:00:00 2001 From: xiezhipeng Date: Mon, 8 Aug 2022 14:05:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=86=85=E5=AD=98=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8=E5=AE=89=E5=85=A8=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=B9=B6=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiezhipeng Change-Id: Ic55764f600c08b247cdacd12ea5152d059022247 --- .../drivers/bluetooth_lite/bluetooth_device.c | 15 +++++++++++++-- .../liteos_m/hals/drivers/wifi_lite/wifi_device.c | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c index 878b6c2..2028554 100755 --- a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c +++ b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c @@ -78,6 +78,7 @@ BtError GetLocalAddr(unsigned char *mac, unsigned int len) } ret = memcpy_s(mac, len, esp_bt_dev_get_address(), len); if (!ret) { + printf("memcpy_s fail!!\n"); return ret; } return BT_SUCCESS; @@ -118,7 +119,12 @@ BtError BleGattcDisconnect(int clientId, int conn_id) BtError BleGapDisconnect(BdAddr remote_device) { uint8_t BdAddrs[OHOS_BD_ADDR_LEN]; - memcpy_s(BdAddrs, sizeof(BdAddrs), remote_device.addr, sizeof(remote_device.addr)); + int ret = 0; + ret = memcpy_s(BdAddrs, sizeof(BdAddrs), remote_device.addr, sizeof(remote_device.addr)); + if (!ret) { + printf("memcpy_s fail!!\n"); + return ret; + } return esp_ble_gap_disconnect(BdAddrs); } @@ -232,7 +238,12 @@ BtError BleGattcRegisterForNotify(GattInterfaceType gattc_if, uint16_t handle) { uint8_t BdAddrs[OHOS_BD_ADDR_LEN]; - memcpy_s(BdAddrs, sizeof(BdAddrs), server_bda.addr, sizeof(server_bda.addr)); + int ret = 0; + ret = memcpy_s(BdAddrs, sizeof(BdAddrs), server_bda.addr, sizeof(server_bda.addr)); + if (!ret) { + printf("memcpy_s fail!!\n"); + return ret; + } return esp_ble_gattc_register_for_notify(gattc_if, BdAddrs, handle); } diff --git a/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c b/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c index ce40035..0119288 100755 --- a/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c +++ b/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c @@ -354,7 +354,7 @@ int DeviceWifiStart(void) { esp_err_t err; DevWifiInfo_t *info = &DevWifiInfo; - memset_s(info, sizeof(DevWifiInfo_t), 0, sizeof(*info)); + MEMCPY_S(info, sizeof(DevWifiInfo_t), 0, sizeof(*info)); for (unsigned i = 0; i < WIFI_MAX_CONFIG_SIZE; i++) { info->config[i].netId = WIFI_CONFIG_INVALID; } @@ -557,7 +557,7 @@ WifiErrorCode RemoveDevice(int networkId) } WifiLock(); - memset_s(&info->config[networkId], sizeof(WifiDeviceConfig), 0, sizeof(WifiDeviceConfig)); + MEMCPY_S(&info->config[networkId], sizeof(WifiDeviceConfig), 0, sizeof(WifiDeviceConfig)); info->config[networkId].netId = WIFI_CONFIG_INVALID; WifiUnlock(); return WIFI_SUCCESS; @@ -726,7 +726,7 @@ WifiErrorCode GetLinkedInfo(WifiLinkedInfo *result) if (!result) { return ERROR_WIFI_INVALID_ARGS; } - memset_s(result, sizeof(WifiLinkedInfo), 0, sizeof(WifiLinkedInfo)); + MEMCPY_S(result, sizeof(WifiLinkedInfo), 0, sizeof(WifiLinkedInfo)); if (info->staStatus != WIFI_ACTIVE) return ERROR_WIFI_NOT_STARTED; @@ -780,7 +780,7 @@ WifiErrorCode GetStationList(StationInfo *result, unsigned int *size) if (*size < staNum) { staNum = *size; } - memset_s(result, (sizeof(result[0]) * staNum), 0, sizeof(result[0]) * staNum); + MEMCPY_S(result, (sizeof(result[0]) * staNum), 0, sizeof(result[0]) * staNum); for (unsigned int i = 0; i < staNum; i++) { MEMCPY_S(result[i].macAddress, sizeof(result[i].macAddress), wifi_sta_list.sta[i].mac, sizeof(wifi_sta_list.sta[i].mac)); From 889628f5ef6145ea9a159330c32c0fd2fb99cf36 Mon Sep 17 00:00:00 2001 From: xiezhipeng Date: Mon, 8 Aug 2022 14:12:50 +0800 Subject: [PATCH 2/2] --amend Signed-off-by: xiezhipeng Change-Id: Ie5ee47b60ee274c7a78e27f1522df53398b089f7 --- .../drivers/bluetooth_lite/bluetooth_device.c | 2 +- .../drivers/bluetooth_lite/bluetooth_device.h | 2 +- .../hals/drivers/wifi_lite/wifi_device.c | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c index 2028554..68f9ff1 100755 --- a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c +++ b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.c @@ -100,7 +100,7 @@ BtError BleStopScan(void) return esp_ble_gap_stop_scanning(); } -BtError BleGattcConnect(int clientId, void *func, +BtError BleGattcConnect(int clientId, VOID *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport) { diff --git a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.h b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.h index a603c5e..3a8e8fa 100755 --- a/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.h +++ b/niobeu4/liteos_m/hals/drivers/bluetooth_lite/bluetooth_device.h @@ -135,7 +135,7 @@ typedef struct { uint16_t end_handle; } GattcGetChar; -BtError BleGattcConnect(int clientId, void *func, const BdAddr *bdAddr, bool isAutoConnect, +BtError BleGattcConnect(int clientId, VOID *func, const BdAddr *bdAddr, bool isAutoConnect, BtTransportType transport); BtError BleGattcDisconnect(int clientId, int conn_id); diff --git a/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c b/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c index 0119288..508c297 100755 --- a/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c +++ b/niobeu4/liteos_m/hals/drivers/wifi_lite/wifi_device.c @@ -84,7 +84,7 @@ static DevWifiInfo_t DevWifiInfo = {0}; static const char TAG[] = {"WifiLite."}; static const char NullBssid[WIFI_MAC_LEN] = {0, 0, 0, 0, 0, 0}; -static void MEMCPY_S(void *dst, int dstSize, void *src, int srcSize) +static void MEMCPY_S(VOID *dst, int dstSize, VOID *src, int srcSize) { if ((dst == NULL) || (src == NULL)) { return; @@ -261,13 +261,13 @@ static void SendOnHotspotStateChanged(DevWifiInfo_t *info, WifiEventState event) } } -static void event_got_ip_handler(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) +static void event_got_ip_handler(VOID *arg, esp_event_base_t event_base, + int32_t event_id, VOID *event_data) { DevWifiInfo.ip_ok = 1; } -static void wifi_event_scan_down_proc(void *event_data) +static void wifi_event_scan_down_proc(VOID *event_data) { uint16_t size = 0; DevWifiInfo.scan_ok = 1; @@ -275,7 +275,7 @@ static void wifi_event_scan_down_proc(void *event_data) SendOnWifiScanStateChanged(&DevWifiInfo, WIFI_STATE_AVAILABLE, size); } -static void wifi_event_sta_connected_proc(void *event_data) +static void wifi_event_sta_connected_proc(VOID *event_data) { WifiLinkedInfo linkInfo = {0}; wifi_ap_record_t ap_info; @@ -288,7 +288,7 @@ static void wifi_event_sta_connected_proc(void *event_data) SendOnWifiConnectionChanged(&DevWifiInfo, WIFI_STATE_AVAILABLE, &linkInfo); } -static void wifi_event_sta_disconnected_proc(void *event_data) +static void wifi_event_sta_disconnected_proc(VOID *event_data) { WifiLinkedInfo linkInfo = {0}; wifi_event_sta_disconnected_t *disconnected = (wifi_event_sta_disconnected_t *)event_data; @@ -299,7 +299,7 @@ static void wifi_event_sta_disconnected_proc(void *event_data) SendOnWifiConnectionChanged(&DevWifiInfo, WIFI_STATE_NOT_AVAILABLE, &linkInfo); } -static void wifi_event_ap_connected_proc(void *event_data) +static void wifi_event_ap_connected_proc(VOID *event_data) { StationInfo staInfo = {0}; wifi_event_ap_staconnected_t *connect_event = (wifi_event_ap_staconnected_t *)event_data; @@ -307,7 +307,7 @@ static void wifi_event_ap_connected_proc(void *event_data) SendOnHotspotStaJoin(&DevWifiInfo, &staInfo); } -static void wifi_event_ap_disconnected_proc(void *event_data) +static void wifi_event_ap_disconnected_proc(VOID *event_data) { StationInfo staInfo = {0}; wifi_event_ap_stadisconnected_t *disconnect_event = (wifi_event_ap_stadisconnected_t *)event_data; @@ -317,13 +317,13 @@ static void wifi_event_ap_disconnected_proc(void *event_data) SendOnHotspotStaLeave(&DevWifiInfo, &staInfo); } -static void wifi_event_ap_start_proc(void *event_data) +static void wifi_event_ap_start_proc(VOID *event_data) { SendOnHotspotStateChanged(&DevWifiInfo, WIFI_STATE_AVAILABLE); } -static void event_handler(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) +static void event_handler(VOID *arg, esp_event_base_t event_base, + int32_t event_id, VOID *event_data) { LOG("event=%d", event_id); switch (event_id) {