diff --git a/model/network/common/netdevice/net_device.c b/model/network/common/netdevice/net_device.c index da504d16e93281209d0f233c18c9c151bba9aaeb..2a336b3048b5d5e132fe797450fe423718664d8d 100644 --- a/model/network/common/netdevice/net_device.c +++ b/model/network/common/netdevice/net_device.c @@ -17,12 +17,12 @@ static struct NetDeviceImpl *g_netDeviceImplTable[MAX_NETDEVICE_COUNT] = {NULL}; -static bool FindAvailableTable(int32_t *index) +static bool FindAvailableTable(uint32_t *index) { - int32_t i; + uint32_t i; if (index == NULL) { - HDF_LOGE("Find Available table index error!"); + HDF_LOGE("%s Find Available table index error!", __func__); return false; } for (i = 0; i < MAX_NETDEVICE_COUNT; i++) { @@ -34,7 +34,7 @@ static bool FindAvailableTable(int32_t *index) return false; } -static bool AddNetDeviceImplToTable(int32_t index, struct NetDeviceImpl *netDeviceImpl) +static bool AddNetDeviceImplToTable(uint32_t index, struct NetDeviceImpl *netDeviceImpl) { if (index >= MAX_NETDEVICE_COUNT) { HDF_LOGE("%s error because of not enough space!", __func__); @@ -68,7 +68,6 @@ static struct NetDeviceImpl *InitNetDeviceImpl(NetDevice *nd, NetIfCategory ifCa HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__); return NULL; } - (void)memset_s(ndImpl, sizeof(struct NetDeviceImpl), 0, sizeof(struct NetDeviceImpl)); ndImpl->netDevice = nd; if (RegisterNetDeviceImpl(ndImpl) != HDF_SUCCESS) { @@ -100,6 +99,7 @@ static void DeInitNetDeviceImpl(struct NetDeviceImpl *netDeviceImpl) /* last release netDeviceImpl */ OsalMemFree(netDeviceImpl); + netDeviceImpl = NULL; HDF_LOGI("%s success!", __func__); return; } @@ -117,7 +117,7 @@ static struct NetDeviceImpl *GetImplByNetDevice(const struct NetDevice *netDevic } } } - HDF_LOGE("Don't Get Impl by netdevice"); + HDF_LOGE("%s Get Impl by netdevice failed", __func__); return ndImpl; } @@ -125,7 +125,7 @@ struct NetDevice *NetDeviceInit(const char *ifName, uint32_t len, NetIfCategory { NetDevice *netDevice = NULL; struct NetDeviceImpl *ndImpl = NULL; - int32_t index = 0; + uint32_t index = 0; int32_t ret; if ((ifName == NULL) || (strlen(ifName) != len) || (strlen(ifName) > IFNAMSIZ - 1)) { @@ -137,9 +137,8 @@ struct NetDevice *NetDeviceInit(const char *ifName, uint32_t len, NetIfCategory HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__); return NULL; } - (void)memset_s(netDevice, sizeof(NetDevice), 0, sizeof(NetDevice)); - if (memcpy_s(netDevice->name, IFNAMSIZ, ifName, len + 1) != EOK) { - HDF_LOGE("%s fail: memcpy_s fail!", __func__); + if (strcpy_s(netDevice->name, IFNAMSIZ, ifName) != EOK) { + HDF_LOGE("%s fail: strcpy_s fail!", __func__); OsalMemFree(netDevice); return NULL; } @@ -318,7 +317,7 @@ static int32_t NetIfRxImpl(const struct NetDevice *netDevice, NetBuf *buff, Rece ProcessingResult ret = PROCESSING_CONTINUE; if (ndImpl == NULL || ndImpl->interFace == NULL || ndImpl->interFace->receive == NULL) { - HDF_LOGE("NetIfRxImpl fail : netdevice not exist!"); + HDF_LOGE("%s: NetIfRxImpl fail : netdevice not exist!", __func__); return HDF_ERR_INVALID_PARAM; } @@ -333,7 +332,7 @@ static int32_t NetIfRxImpl(const struct NetDevice *netDevice, NetBuf *buff, Rece HDF_LOGI("NetIfRxImpl specialEtherType Process not need TCP/IP stack!"); return HDF_SUCCESS; } else { - HDF_LOGE("NetIfRxImpl specialEtherType Process error"); + HDF_LOGE("%s: NetIfRxImpl specialEtherType Process error", __func__); return HDF_FAILURE; } } diff --git a/model/network/wifi/core/compoments/eapol/eapol.c b/model/network/wifi/core/components/eapol/eapol.c similarity index 98% rename from model/network/wifi/core/compoments/eapol/eapol.c rename to model/network/wifi/core/components/eapol/eapol.c index f1e02bbc5c4c2b437a3dc3dc1eda8d7ec74fc7cf..43811b2258684611f5b394a874617f0e8a90a045 100644 --- a/model/network/wifi/core/compoments/eapol/eapol.c +++ b/model/network/wifi/core/components/eapol/eapol.c @@ -75,7 +75,7 @@ static int32_t GetEapol(const struct NetDevice *netDevice, struct EapolRx *buff) p = NetBufGetAddress(netBuff, E_DATA_BUF); len = NetBufGetDataLen(netBuff); if (len > eapolRx->len) { - HDF_LOGE("%s fail : eapolRx->len too small! netBuff->len(%d) > eapolRx->len(%d).", + HDF_LOGE("%s fail : eapolRx->len too small! netBuff->len(%u) > eapolRx->len(%u).", __func__, netBuff->len, eapolRx->len); NetBufFree(netBuff); return HDF_FAILURE; @@ -158,7 +158,7 @@ static void HandleEapolQueue(struct EapolData *eapol) HDF_LOGE("%s discard pre netbuf : intervalTime(%lld) > EAPOL_MAX_ENQUEUE_TIME.", __func__, intervalTime); } else { - HDF_LOGE("%s discard pre netbuf : eapol->count(%d) = maxCount(%d).", __func__, eapol->count, maxCount); + HDF_LOGE("%s discard pre netbuf : eapol->count(%u) = maxCount(%u).", __func__, eapol->count, maxCount); } eapol->count--; eapol->enqueueTime = currentTime; diff --git a/model/network/wifi/core/compoments/eapol/eapol.h b/model/network/wifi/core/components/eapol/eapol.h similarity index 97% rename from model/network/wifi/core/compoments/eapol/eapol.h rename to model/network/wifi/core/components/eapol/eapol.h index d82b6c69f518ef49c7ee27487cb1cc3d118a5fc1..bebfdf9a2264772ba23f30b4c0240705852c5f47 100644 --- a/model/network/wifi/core/compoments/eapol/eapol.h +++ b/model/network/wifi/core/components/eapol/eapol.h @@ -16,7 +16,7 @@ #define EAPOL_MAX_ENQUEUE_TIME 300 /* 300 Second */ struct EapolData { - bool regFlag; /* is already regstered */ + bool regFlag; /* is already registered */ uint16_t count; /* eapol frame count in NetBuffQueue. */ uint16_t maxCount; int64_t enqueueTime; /* record eapol frame time for dfx. */ diff --git a/model/network/wifi/core/compoments/softap/ap.c b/model/network/wifi/core/components/softap/ap.c similarity index 99% rename from model/network/wifi/core/compoments/softap/ap.c rename to model/network/wifi/core/components/softap/ap.c index 21daac1a325d8f9e7270f75f849b60b86e72a17a..d685abed7f9b77c0cabaf84d50cf994c1743da98 100644 --- a/model/network/wifi/core/compoments/softap/ap.c +++ b/model/network/wifi/core/components/softap/ap.c @@ -72,7 +72,7 @@ static int32_t StartAp(struct NetDevice *netDev, WifiApSetting *apSettings) RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->apOps, ConfigAp); ret = chipDriver->apOps->ConfigAp(netDev, &apConf); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s:ConfigAp failed!ret=%d", ret); + HDF_LOGE("%s:ConfigAp failed!ret=%d", __func__, ret); return HDF_FAILURE; } @@ -378,7 +378,6 @@ static int32_t WifiCmdGetAssociatedStas(const RequestContext *context, struct Hd ret = GetAssociatedStas(netdev, num, rspData); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: fail to GetAssociatedStas,%d", __func__, ret); - return ret; } return ret; } diff --git a/model/network/wifi/core/compoments/softap/ap.h b/model/network/wifi/core/components/softap/ap.h similarity index 100% rename from model/network/wifi/core/compoments/softap/ap.h rename to model/network/wifi/core/components/softap/ap.h diff --git a/model/network/wifi/core/compoments/sta/sta.c b/model/network/wifi/core/components/sta/sta.c similarity index 100% rename from model/network/wifi/core/compoments/sta/sta.c rename to model/network/wifi/core/components/sta/sta.c diff --git a/model/network/wifi/core/compoments/sta/sta.h b/model/network/wifi/core/components/sta/sta.h similarity index 100% rename from model/network/wifi/core/compoments/sta/sta.h rename to model/network/wifi/core/components/sta/sta.h diff --git a/model/network/wifi/core/hdf_wifi_core.c b/model/network/wifi/core/hdf_wifi_core.c index 3217906135b0d1d291b262f0653dd7a091c817a9..75c26ae9265033aa670780cd65a3bbe5bce2c547 100644 --- a/model/network/wifi/core/hdf_wifi_core.c +++ b/model/network/wifi/core/hdf_wifi_core.c @@ -39,13 +39,13 @@ int32_t HdfWifiGetBusIdx(void) * @brief as for now, we just support one wlan module in one board cause driver binds to wlan featere * due to that reason, once we detected one chip, we stop rescan. */ -int HdfWlanSdioScan(struct HdfWlanDevice *data, struct HdfConfigWlanBus *busConfig) +int32_t HdfWlanSdioScan(struct HdfWlanDevice *data, struct HdfConfigWlanBus *busConfig) { /* get config vendId, deviceId and chip-name which used in detect match process */ HdfWlanGetSdioTableByConfig(); HdfWlanSdioScanTriggerByBusIndex(busConfig->busIdx); - int ret = HdfWlanGetDetectedChip(data, busConfig); + int32_t ret = HdfWlanGetDetectedChip(data, busConfig); HdfWlanSdioDriverUnReg(); if (ret != HDF_SUCCESS) { return ret; @@ -54,7 +54,7 @@ int HdfWlanSdioScan(struct HdfWlanDevice *data, struct HdfConfigWlanBus *busConf return HDF_SUCCESS; } -static int HdfWifiDriverBind(struct HdfDeviceObject *dev) +static int32_t HdfWifiDriverBind(struct HdfDeviceObject *dev) { ErrorCode errCode; static struct IDeviceIoService wifiService = { @@ -179,7 +179,7 @@ static struct HdfChipDriverFactory *HdfWlanGetDriverFactory(const char *driverNa static int32_t HdfWlanDeinitInterface(struct HdfWlanDevice *device, const char *ifName, struct HdfChipDriverFactory *factory) { - int ret; + int32_t ret; struct NetDevice *netdev = NULL; struct HdfChipDriver *chipDriver = NULL; @@ -369,7 +369,7 @@ static struct HdfWlanDevice *ProbeDevice(struct HdfConfigWlanDevInst *deviceConf return device; } -int32_t DeinitDevice(struct HdfWlanDevice *device) +int32_t HdfWifiDeinitDevice(struct HdfWlanDevice *device) { struct HdfChipDriverFactory *chipDriverFact = NULL; int32_t ret; @@ -394,7 +394,7 @@ int32_t DeinitDevice(struct HdfWlanDevice *device) return HDF_SUCCESS; } -int32_t InitDevice(struct HdfWlanDevice *device) +int32_t HdfWifiInitDevice(struct HdfWlanDevice *device) { int32_t ret; struct HdfChipDriverFactory *chipDriverFact = NULL; @@ -424,7 +424,7 @@ int32_t InitDevice(struct HdfWlanDevice *device) /* thread callback function */ static int32_t HdfWlanInitThread(void *para) { - const uint32_t initDelaySec = 5; + const uint32_t initDelaySec = 15; struct HdfDeviceObject *device = (struct HdfDeviceObject *)para; struct SubscriberCallback callback = { NULL }; struct HdfConfigWlanDeviceList *devList = NULL; @@ -465,7 +465,7 @@ static int32_t HdfWlanInitThread(void *para) // Load chip driver (void)DevSvcManagerClntSubscribeService(wlanDevice->driverName, callback); - (void)InitDevice(wlanDevice); + (void)HdfWifiInitDevice(wlanDevice); } HDF_LOGV("%s:finished.", __func__); diff --git a/model/network/wifi/core/hdf_wifi_core.h b/model/network/wifi/core/hdf_wifi_core.h index c171fd6187e3d3db350d20be011d6e88a159d6f9..78134dc5e333f916bf245fa35672d4f151919a6a 100644 --- a/model/network/wifi/core/hdf_wifi_core.h +++ b/model/network/wifi/core/hdf_wifi_core.h @@ -17,9 +17,9 @@ extern "C" { #endif int32_t HdfWifiGetBusIdx(void); -int32_t DeinitDevice(struct HdfWlanDevice *device); +int32_t HdfWifiDeinitDevice(struct HdfWlanDevice *device); -int32_t InitDevice(struct HdfWlanDevice *device); +int32_t HdfWifiInitDevice(struct HdfWlanDevice *device); #ifdef __cplusplus } diff --git a/model/network/wifi/core/module/wifi_base.c b/model/network/wifi/core/module/wifi_base.c index 072e10b75e73be83e739f5598a6515cc90cfcfb4..6f291138754726fe06c5baac744584d3ed93d4bf 100644 --- a/model/network/wifi/core/module/wifi_base.c +++ b/model/network/wifi/core/module/wifi_base.c @@ -374,7 +374,7 @@ static int32_t WifiCmdEnableEapol(const RequestContext *context, struct HdfSBuf } eapol.callback = (void *)HdfWifiEventEapolRecv; - eapol.contex = NULL; + eapol.context = NULL; return EnableEapol(netdev, &eapol); } @@ -486,19 +486,19 @@ static int32_t WifiFillHwFeature(struct NetDevice *netdev, WifiHwFeatureData *fe do { uint32_t loop; if (capability->supportedRateCount > MAX_SUPPORTED_RATE) { - HDF_LOGE("%s: bitrates %d out of range", __func__, capability->supportedRateCount); + HDF_LOGE("%s: bitrates %u out of range", __func__, capability->supportedRateCount); ret = HDF_FAILURE; break; } for (loop = 0; loop < capability->supportedRateCount; ++loop) { - HDF_LOGV("%s: supported rate %d", __func__, capability->supportedRates[loop]); + HDF_LOGV("%s: supported rate %u", __func__, capability->supportedRates[loop]); featureData->bitrate[loop] = capability->supportedRates[loop]; } if (capability->bands[IEEE80211_BAND_2GHZ] != NULL) { struct WlanBand *band = capability->bands[IEEE80211_BAND_2GHZ]; if (band->channelCount > WIFI_24G_CHANNEL_NUM) { - HDF_LOGE("%s: channels %d out of range", __func__, band->channelCount); + HDF_LOGE("%s: channels %u out of range", __func__, band->channelCount); ret = HDF_FAILURE; break; } @@ -630,13 +630,10 @@ static int32_t SetNetIfInfo(struct NetDevice *netdev, uint32_t type) static int32_t UnsetNetIfInfo(struct NetDevice *netdev) { - int ret; - (void)netdev->netDeviceIf->stop(netdev); (void)NetIfDhcpStop(netdev); (void)NetIfDhcpsStop(netdev); - ret = NetIfSetStatus(netdev, NETIF_DOWN); - return ret; + return NetIfSetStatus(netdev, NETIF_DOWN); } static void SetNetworkAddr(struct NetDevice *netdev, uint32_t type) @@ -646,13 +643,13 @@ static void SetNetworkAddr(struct NetDevice *netdev, uint32_t type) IpV4Addr gw; if (type == WIFI_IFTYPE_STATION) { - ip.addr = 0x00000000UL; // 0, 0, 0, 0 - netmask.addr = 0x00000000UL; // 0, 0, 0, 0 - gw.addr = 0x00000000UL; // 0, 0, 0, 0 + ip.addr = 0x00000000UL; + netmask.addr = 0x00000000UL; + gw.addr = 0x00000000UL; } else { - ip.addr = 0x010ca8c0UL; // 192, 168, 12, 1 - netmask.addr = 0x00ffffffUL; // 255, 255, 255, 0 - gw.addr = 0x010ca8c0UL; // 192, 168, 12, 1 + ip.addr = 0x010ca8c0UL; + netmask.addr = 0x00ffffffUL; + gw.addr = 0x010ca8c0UL; } if (netdev != NULL) { @@ -662,9 +659,9 @@ static void SetNetworkAddr(struct NetDevice *netdev, uint32_t type) static void UnsetNetworkAddr(struct NetDevice *netdev) { - IpV4Addr ip = { 0x00000000UL }; // 0, 0, 0, 0 - IpV4Addr netmask = { 0x00000000UL }; // 0, 0, 0, 0 - IpV4Addr gw = { 0x00000000UL }; // 0, 0, 0, 0 + IpV4Addr ip = { 0x00000000UL }; + IpV4Addr netmask = { 0x00000000UL }; + IpV4Addr gw = { 0x00000000UL }; if (netdev != NULL) { NetIfSetAddr(netdev, &ip, &netmask, &gw); @@ -1058,9 +1055,7 @@ static int32_t WifiCmdGetIfNamesByChipId(const RequestContext *context, struct H break; } } while (false); - if (ifNames != NULL) { - OsalMemFree(ifNames); - } + OsalMemFree(ifNames); return ret; } @@ -1135,12 +1130,12 @@ static int32_t WifiCmdDoResetChip(const RequestContext *context, struct HdfSBuf } wlanDevice = HdfWlanGetWlanDevice(chipId); - if (wlanDevice == NULL) { - HDF_LOGE("%s: wlanDevice is NULL, not found!", __func__); + if (wlanDevice == NULL || wlanDevice->reset == NULL) { + HDF_LOGE("%s: wlanDevice or wlanDevice->reset is NULL!", __func__); return HDF_FAILURE; } - ret = DeinitDevice(wlanDevice); + ret = HdfWifiDeinitDevice(wlanDevice); if (ret != HDF_SUCCESS) { return ret; } @@ -1152,7 +1147,7 @@ static int32_t WifiCmdDoResetChip(const RequestContext *context, struct HdfSBuf return ERR_POWER_RESET_FAIL; } - ret = InitDevice(wlanDevice); + ret = HdfWifiInitDevice(wlanDevice); return ret; } @@ -1190,6 +1185,10 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf } struct HdfSBuf *data = HdfSBufCopy(reqData); + if (data == NULL) { + HDF_LOGE("%s: sbuf copy fail", __func__); + return HDF_FAILURE; + } ret = g_baseService->SendAsyncMessage(g_baseService, BASE_SERVICE_ID, CMD_BASE_DO_RESET_PRIVATE, data, SendMessageResetDriverCallBack); diff --git a/model/network/wifi/include/hdf_wifi_cmd.h b/model/network/wifi/include/hdf_wifi_cmd.h index aee3f94129d46402c9902c5cbcd463318336ee1f..9f0f17c000d28f3904341c667ea2ba3517e3bfec 100644 --- a/model/network/wifi/include/hdf_wifi_cmd.h +++ b/model/network/wifi/include/hdf_wifi_cmd.h @@ -278,7 +278,7 @@ typedef struct { typedef struct { void *callback; - void *contex; + void *context; } WifiEnableEapol; typedef struct { diff --git a/model/network/wifi/platform/include/hdf_wlan_services.h b/model/network/wifi/platform/include/hdf_wlan_services.h index e419062dd05a4c4d98c460e3067160ad53222e2d..cbc7e5fbc33ac049c87e53bd9a4353f229cfe2fc 100644 --- a/model/network/wifi/platform/include/hdf_wlan_services.h +++ b/model/network/wifi/platform/include/hdf_wlan_services.h @@ -29,7 +29,6 @@ enum BaseCommands { CMD_BASE_GET_ADDR, CMD_BASE_SET_MODE, CMD_BASE_GET_HW_FEATURE = 10, -// CMD_BASE_SCAN, CMD_BASE_SET_NETDEV, CMD_BASE_SEND_ACTION, CMD_BASE_SET_CLIENT, diff --git a/model/network/wifi/platform/include/message/message_config.h b/model/network/wifi/platform/include/message/message_config.h index 1a301bcb16a169f46d202b7c9c003034001c398f..cc2d47eac962067e1f7aa65bea339748ed25a47c 100644 --- a/model/network/wifi/platform/include/message/message_config.h +++ b/model/network/wifi/platform/include/message/message_config.h @@ -6,8 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#ifndef __MESSAGE_CONFIG_H__ -#define __MESSAGE_CONFIG_H__ +#ifndef MESSAGE_CONFIG_H +#define MESSAGE_CONFIG_H #include "message_types.h" #ifndef MESSAGE_ENGINE_MAX_SERVICE diff --git a/model/network/wifi/platform/include/message/message_types.h b/model/network/wifi/platform/include/message/message_types.h index 32dce6f5826faea6072dfa1ffa6f4790884f6529..b973d4c6f09a530cdca3dd7fdd60f26b08ef565a 100644 --- a/model/network/wifi/platform/include/message/message_types.h +++ b/model/network/wifi/platform/include/message/message_types.h @@ -6,8 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#ifndef __MESSAGE_TYPES_H__ -#define __MESSAGE_TYPES_H__ +#ifndef MESSAGE_TYPES_H +#define MESSAGE_TYPES_H #include "hdf_base.h" typedef uint8_t NodeId; diff --git a/model/network/wifi/platform/include/message/sidecar.h b/model/network/wifi/platform/include/message/sidecar.h index 4e1d7f59bdbdaba626b35891c622fffd7ce32b49..10155c118489415924db812f75511889f7621a38 100644 --- a/model/network/wifi/platform/include/message/sidecar.h +++ b/model/network/wifi/platform/include/message/sidecar.h @@ -6,8 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#ifndef __SIDECAR_H__ -#define __SIDECAR_H__ +#ifndef SIDECAR_H +#define SIDECAR_H #include "hdf_base.h" #include "hdf_device_desc.h" #include "osal/osal_sem.h" @@ -29,7 +29,7 @@ enum MessageType { uint8_t senderId; \ uint8_t receiverId; \ uint8_t requestType; \ - bool corssNode; \ + bool crossNode; \ struct HdfDeviceIoClient *client #define RESERVED_SERVICE_ID 0 diff --git a/model/network/wifi/platform/src/hdf_wlan_chipdriver_manager.c b/model/network/wifi/platform/src/hdf_wlan_chipdriver_manager.c index 63a47e9c9c27ede37a8958ec0c5a9ad34078732e..85580e6bda3f11d3b31a49a92be6148b77a5cb8a 100644 --- a/model/network/wifi/platform/src/hdf_wlan_chipdriver_manager.c +++ b/model/network/wifi/platform/src/hdf_wlan_chipdriver_manager.c @@ -46,13 +46,13 @@ int32_t HdfWlanRegChipDriver(struct HdfChipDriverFactory *obj) return HDF_ERR_INVALID_PARAM; } if (HdfWlanGetChipDriverByName(obj->driverName) != NULL) { - HDF_LOGW("%s: chipdriver factory is already registed.name=%s", __func__, obj->driverName); + HDF_LOGW("%s: chipdriver factory is already registered.name=%s", __func__, obj->driverName); return HDF_SUCCESS; } for (index = 0; index < MAX_CHIPDRIVER_COUNT; index++) { if (g_wlanChipDriverManagerFactory[index] == NULL) { g_wlanChipDriverManagerFactory[index] = obj; - HDF_LOGI("%s:Chip driver %s registed.", __func__, obj->driverName); + HDF_LOGI("%s:Chip driver %s registered.", __func__, obj->driverName); return HDF_SUCCESS; } } diff --git a/model/network/wifi/platform/src/hdf_wlan_config_parser.c b/model/network/wifi/platform/src/hdf_wlan_config_parser.c index b55b3935866b7d0f00ee5eefea27dcd4b82fed6a..d32facbbb67215f0c6aaa79b82ed88a06a9b65e1 100644 --- a/model/network/wifi/platform/src/hdf_wlan_config_parser.c +++ b/model/network/wifi/platform/src/hdf_wlan_config_parser.c @@ -35,7 +35,7 @@ static int32_t ParseWlanStaConfig(const struct DeviceResourceNode *node, struct HDF_LOGE("%s: GetUint8 fail!", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: name=%s, mode=%d!", __func__, staConfig->name, staConfig->mode); + HDF_LOGD("%s: name=%s, mode=%u!", __func__, staConfig->name, staConfig->mode); return HDF_SUCCESS; } @@ -73,7 +73,7 @@ static int32_t ParseWlanApConfig(const struct DeviceResourceNode *node, struct H HDF_LOGE("%s: get userResNum fail!", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: name=%s, mode=%d, vapResNum=%d, userResNum=%d!", __func__, apConfig->name, apConfig->mode, + HDF_LOGD("%s: name=%s, mode=%u, vapResNum=%u, userResNum=%u!", __func__, apConfig->name, apConfig->mode, apConfig->vapResNum, apConfig->userResNum); return HDF_SUCCESS; } @@ -102,7 +102,7 @@ static int32_t ParseWlanP2PConfig(const struct DeviceResourceNode *node, struct HDF_LOGE("%s: mode fail!", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: name=%s, mode=%d", __func__, p2pConfig->name, p2pConfig->mode); + HDF_LOGD("%s: name=%s, mode=%u", __func__, p2pConfig->name, p2pConfig->mode); return HDF_SUCCESS; } @@ -125,7 +125,7 @@ static int32_t ParseWlanMac80211Config(const struct DeviceResourceNode *node, st HDF_LOGE("%s: mode fail!", __func__); return HDF_FAILURE; } - HDF_LOGD("%s: mode=%d", __func__, macConfig->mode); + HDF_LOGD("%s: mode=%u", __func__, macConfig->mode); return HDF_SUCCESS; } @@ -211,10 +211,11 @@ static int32_t ParseWlanModuleConfig(const struct DeviceResourceNode *node, stru return HDF_SUCCESS; } /* BEGIN for WLAN2.1 : Added by hdf-wlan */ -static int32_t ParseWlanPowerConfig(const struct DeviceResourceNode *node, struct HdfConfigWlanPower *masterPowerConfig) +static int32_t ParseWlanPowerConfig(const struct DeviceResourceNode *node, + struct HdfConfigWlanPower *primaryPowerConfig) { struct DeviceResourceIface *drsOps = NULL; - if (node == NULL || masterPowerConfig == NULL) { + if (node == NULL || primaryPowerConfig == NULL) { HDF_LOGE("%s: one of the input para is NULL!", __func__); return HDF_FAILURE; } @@ -224,21 +225,21 @@ static int32_t ParseWlanPowerConfig(const struct DeviceResourceNode *node, struc return HDF_FAILURE; } - if (drsOps->GetUint8(node, "powerSeqDelay", &masterPowerConfig->powerSeqDelay, 0) != HDF_SUCCESS) { + if (drsOps->GetUint8(node, "powerSeqDelay", &primaryPowerConfig->powerSeqDelay, 0) != HDF_SUCCESS) { HDF_LOGE("%s: powersSeqDelay fail!", __func__); return HDF_FAILURE; } - if (drsOps->GetUint8(node, "powerType", &masterPowerConfig->powerType, 0) != HDF_SUCCESS) { + if (drsOps->GetUint8(node, "powerType", &primaryPowerConfig->powerType, 0) != HDF_SUCCESS) { HDF_LOGE("%s: powerType fail!", __func__); return HDF_FAILURE; } - if (drsOps->GetUint8(node, "gpioId", &masterPowerConfig->gpioId, 0) != HDF_SUCCESS) { + if (drsOps->GetUint8(node, "gpioId", &primaryPowerConfig->gpioId, 0) != HDF_SUCCESS) { HDF_LOGE("%s: gpioId fail!", __func__); return HDF_FAILURE; } - if (drsOps->GetUint8(node, "activeLevel", &masterPowerConfig->activeLevel, 0) != HDF_SUCCESS) { + if (drsOps->GetUint8(node, "activeLevel", &primaryPowerConfig->activeLevel, 0) != HDF_SUCCESS) { HDF_LOGE("%s: activeLevel fail!", __func__); return HDF_FAILURE; } @@ -269,7 +270,7 @@ static int32_t ParseWlanPowersConfig(const struct DeviceResourceNode *node, stru } const struct DeviceResourceNode *secPowerNode = drsOps->GetChildNode(node, "power1"); - if (fstPowerNode == NULL) { + if (secPowerNode == NULL) { HDF_LOGE("%s: get power1 config fail!", __func__); return HDF_FAILURE; } @@ -451,7 +452,6 @@ static int32_t ParseWlanChipSdioConfig(const struct DeviceResourceNode *node, st HDF_LOGE("%s: deviceId fail!", __func__); return HDF_FAILURE; } - HDF_LOGI("%s: SDIO vendor=%u, device=%u", __func__, sdioArgs->vendorId, sdioArgs->deviceId[0]); return HDF_SUCCESS; } diff --git a/model/network/wifi/platform/src/hdf_wlan_power_manager.c b/model/network/wifi/platform/src/hdf_wlan_power_manager.c index 09494aba6122698d5e357e28c0f7d2f43e356c8f..50592e734d3d5c9092a774b0dd9707524ea20668 100644 --- a/model/network/wifi/platform/src/hdf_wlan_power_manager.c +++ b/model/network/wifi/platform/src/hdf_wlan_power_manager.c @@ -16,13 +16,13 @@ /* power manager begin */ enum PowerType { - PowerNotManaged = 0, - PowerManagedByGPIO = 1 + POWER_NOT_MANAGED = 0, + POWER_MANAGED_BY_GPIO = 1 }; enum GPIOActiveLevel { - ActiveLow = 0, - ActiveHigh + ACTIVE_LOW = 0, + ACTIVE_HIGH }; /* powerCount=1 single power source */ @@ -44,7 +44,7 @@ static int32_t HdfWlanSinglePowerActive(struct HdfConfigWlanPower* powerDate) HDF_LOGE("%s:powerDate is NULL", __func__); return HDF_FAILURE; } - if (powerDate->powerType != PowerNotManaged) { + if (powerDate->powerType != POWER_NOT_MANAGED) { HDF_LOGI("%s:power type is always on", __func__); return HDF_SUCCESS; } @@ -64,14 +64,14 @@ static int32_t HdfWlanSinglePowerActive(struct HdfConfigWlanPower* powerDate) static int32_t HdfWlanSingleDeActive(struct HdfConfigWlanPower* powerDate) { int32_t ret; - uint8_t deActicve; + uint8_t deActive; if (powerDate == NULL) { HDF_LOGE("%s: powerDate is NULL", __func__); return HDF_FAILURE; } - deActicve = !powerDate->activeLevel; - if (powerDate->powerType == PowerNotManaged) { + deActive = !powerDate->activeLevel; + if (powerDate->powerType == POWER_NOT_MANAGED) { HDF_LOGE("%s:power type is not supported in current version", __func__); return HDF_FAILURE; } @@ -80,7 +80,7 @@ static int32_t HdfWlanSingleDeActive(struct HdfConfigWlanPower* powerDate) HDF_LOGE("%s:set dir fail! ret:%d\n", __func__, ret); return ret; } - ret = GpioWrite(powerDate->gpioId, deActicve); + ret = GpioWrite(powerDate->gpioId, deActive); return HDF_SUCCESS; } @@ -138,7 +138,7 @@ int32_t HdfWlanPowerMgrRelease(struct PowerManager* powerMgr) return HDF_SUCCESS; } /** - * @brief create powers manager accoding to the powers config + * @brief create powers manager according to the powers config */ struct PowerManager* HdfWlanCreatePowerManager(const struct HdfConfWlanPowers *configPowers) { diff --git a/model/network/wifi/platform/src/hdf_wlan_product.c b/model/network/wifi/platform/src/hdf_wlan_product.c index 6c75f2ba124e99fc703e402e47c24d9b1271cb5b..3a50385d3394799bfce0566619ceecb87bdc6570 100644 --- a/model/network/wifi/platform/src/hdf_wlan_product.c +++ b/model/network/wifi/platform/src/hdf_wlan_product.c @@ -90,12 +90,15 @@ struct WifiModule *HdfWlanGetModule(void) struct HdfDeviceObject *HdfWlanGetDevice(void) { + if (g_hdfWlanProductData == NULL) { + return NULL; + } return g_hdfWlanProductData->device; } struct HdfWlanDevice *HdfWlanGetWlanDevice(uint8_t chipId) { - if (chipId >= MAX_WLAN_DEVICE) { + if (chipId >= MAX_WLAN_DEVICE || g_hdfWlanProductData == NULL) { return NULL; } return g_hdfWlanProductData->wlanDevice[chipId]; diff --git a/model/network/wifi/platform/src/hdf_wlan_reset_manager.c b/model/network/wifi/platform/src/hdf_wlan_reset_manager.c index 188950b8b43829d393aa99af3594526649ba33b4..595db57577895a438bcb9d7b93de0c076fe2b014 100644 --- a/model/network/wifi/platform/src/hdf_wlan_reset_manager.c +++ b/model/network/wifi/platform/src/hdf_wlan_reset_manager.c @@ -18,8 +18,8 @@ * @brief constant reset manage type */ enum ResetType { - ResetAlwaysOn = 0, - ResetManagedByGPIO = 1 + RESET_ALWAYS_ON = 0, + RESET_MANAGED_BY_GPIO = 1 }; struct HdfWlanResetData { @@ -44,7 +44,7 @@ int32_t HdfChipReset(struct ResetManager *resetManager) return HDF_FAILURE; } resetMgrImpl = (struct ResetManagerImpl*)resetManager; - if (resetMgrImpl->resetData.resetCfg.resetType == ResetAlwaysOn) { + if (resetMgrImpl->resetData.resetCfg.resetType == RESET_ALWAYS_ON) { HDF_LOGE("%s: the reset type is not managed", __func__); return HDF_FAILURE; } @@ -62,7 +62,7 @@ int32_t HdfChipReset(struct ResetManager *resetManager) ret = GpioWrite(resetMgrImpl->resetData.resetCfg.gpioId, !resetMgrImpl->resetData.resetCfg.activeLevel); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: write deactive fail! ret=%d", __func__, ret); + HDF_LOGE("%s: write deactivate fail! ret=%d", __func__, ret); return ret; } OsalMSleep(resetMgrImpl->resetData.bootUpHoldTime); diff --git a/model/network/wifi/platform/src/hdf_wlan_utils.c b/model/network/wifi/platform/src/hdf_wlan_utils.c index 8309ceb8716f90e73e88f16b91f8ec9ec01b56e8..cc92c61ee73cac69c60f17b9bb2cf8f7378a9da8 100644 --- a/model/network/wifi/platform/src/hdf_wlan_utils.c +++ b/model/network/wifi/platform/src/hdf_wlan_utils.c @@ -72,7 +72,7 @@ int32_t RenewNetDevice(NetDevice **netDev) NetDevice *result = NULL; struct HdfWifiNetDeviceData *data = NULL; int32_t ret; - if (netDev == NULL) { + if (netDev == NULL || *netDev == NULL) { HDF_LOGE("%s:NULL ptr!", __func__); return HDF_FAILURE; } @@ -160,7 +160,6 @@ struct NetDevice *AllocPlatformNetDevice(struct HdfWlanDevice *device) ret = GetPlatformIfName(id, ifName, IFNAMSIZ); if (ret != HDF_SUCCESS) { - OsalMemFree(data); break; } #ifdef _PRE_HDF_LINUX @@ -254,7 +253,7 @@ char *HdfWlanGetIfNames(const uint8_t chipId, uint8_t *ifNameCount) return NULL; } - if (ifNameCount == 0) { + if (*ifNameCount == 0) { return ifNames; } diff --git a/model/network/wifi/platform/src/message/message_dispatcher.c b/model/network/wifi/platform/src/message/message_dispatcher.c index 97d5747a333a4029ab4a58122e221035bd6db243..23056b8000bf8661adb6aaf893df256883eccaa1 100644 --- a/model/network/wifi/platform/src/message/message_dispatcher.c +++ b/model/network/wifi/platform/src/message/message_dispatcher.c @@ -36,7 +36,7 @@ void ReleaseMessageContext(MessageContext *context) context->rspData = NULL; } - if (context->corssNode || + if (context->crossNode || (context->requestType != MESSAGE_TYPE_SYNC_REQ && context->requestType != MESSAGE_TYPE_SYNC_RSP)) { // Sync request message may use stack mem.Memory is managed by user if (context->reqData != NULL) { @@ -104,7 +104,7 @@ ErrorCode AppendToLocalDispatcher(MessageDispatcher *dispatcher, const uint8_t p void SetToResponse(MessageContext *context) { if (context->requestType != MESSAGE_TYPE_ASYNC_REQ && context->requestType != MESSAGE_TYPE_SYNC_REQ) { - HDF_LOGE("Only sync and async message can send response!type=%d", context->requestType); + HDF_LOGE("Only sync and async message can send response!type=%u", context->requestType); return; } ServiceId senderId = context->senderId; @@ -124,7 +124,6 @@ static void HandleAsyncResponse(MessageContext *context) } ReleaseMessageContext(context); - context = NULL; } static void HandleSyncResponse(MessageContext *context) @@ -135,7 +134,7 @@ static void HandleSyncResponse(MessageContext *context) } HDF_STATUS status = OsalSemPost(&context->rspSemaphore); if (status != HDF_SUCCESS) { - HDF_LOGE("Send semaphore failed!CMD=%d,Sender=%d,Receiver=%d", context->commandId, context->senderId, + HDF_LOGE("Send semaphore failed!CMD=%u,Sender=%u,Receiver=%u", context->commandId, context->senderId, context->receiverId); } return; @@ -148,13 +147,13 @@ static void HandleRequestMessage(MessageContext *context) RemoteService *rspService = NULL; do { if (targetService == NULL) { - HDF_LOGE("%s:Service %d is not available!", __func__, context->receiverId); + HDF_LOGE("%s:Service %u is not available!", __func__, context->receiverId); errCode = ME_ERROR_NULL_PTR; break; } if (targetService->ExecRequestMsg == NULL) { - HDF_LOGE("%s:Service %d has no ExecMsg method!", __func__, context->receiverId); + HDF_LOGE("%s:Service %u has no ExecMsg method!", __func__, context->receiverId); errCode = ME_ERROR_NULL_PTR; break; } @@ -214,7 +213,7 @@ static void HandleMessage(MessageContext *context) HandleAsyncResponse(context); break; default: - HDF_LOGE("Unsupported message type %d", context->requestType); + HDF_LOGE("Unsupported message type %u", context->requestType); } } } @@ -323,12 +322,7 @@ static ErrorCode StartDispatcher(MessageDispatcher *dispatcher) do { OsalMSleep(1); } while (dispatcher->status == ME_STATUS_STARTTING); - - if (dispatcher->status == ME_STATUS_RUNNING) { - return ME_SUCCESS; - } else { - return ME_ERROR_WRONG_STATUS; - } + return (dispatcher->status == ME_STATUS_RUNNING) ? ME_SUCCESS : ME_ERROR_WRONG_STATUS; } static void ShutdownDispatcher(MessageDispatcher *dispatcher) diff --git a/model/network/wifi/platform/src/message/message_router.c b/model/network/wifi/platform/src/message/message_router.c index ab77a65d7fd49e9dece8002613ff373a89c12faa..3776a3e6639faab4add0ecdd2dbc58a1880e486b 100644 --- a/model/network/wifi/platform/src/message/message_router.c +++ b/model/network/wifi/platform/src/message/message_router.c @@ -6,6 +6,7 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "message_router.h" #include "hdf_base.h" #ifdef USERSPACE_CLIENT_SUPPORT #include @@ -14,7 +15,6 @@ #include "utils/hdf_log.h" #include "osal/osal_mutex.h" #include "securec.h" -#include "message_router.h" #include "message_router_inner.h" #include "message_dispatcher.h" @@ -25,7 +25,7 @@ #endif #ifndef UINT8_MAX -#define UINT8_MAX 256 +#define UINT8_MAX 255 #endif #if MESSAGE_ENGINE_MAX_DISPATCHER > UINT8_MAX @@ -71,7 +71,7 @@ static void ReleaseRemoteService(RemoteService *service) static MessageDispatcher *RefDispatcherInner(const DispatcherId dispatcherId, bool requireLock) { if (dispatcherId >= MESSAGE_ENGINE_MAX_DISPATCHER) { - HDF_LOGE("%s:Input ID is too big.input=%d", __func__, dispatcherId); + HDF_LOGE("%s:Input ID is too big.input=%u", __func__, dispatcherId); return NULL; } @@ -106,7 +106,7 @@ static MessageDispatcher *RefDispatcherInner(const DispatcherId dispatcherId, bo static ErrorCode RegDispatcher(DispatcherId dispatcherId, MessageDispatcher *dispatcher) { if (dispatcherId >= MESSAGE_ENGINE_MAX_DISPATCHER) { - HDF_LOGE("%s:dispatcher id is too big!id=%d", __func__, dispatcherId); + HDF_LOGE("%s:dispatcher id is too big!id=%u", __func__, dispatcherId); return ME_ERROR_PARA_WRONG; } @@ -122,7 +122,7 @@ static ErrorCode RegDispatcher(DispatcherId dispatcherId, MessageDispatcher *dis break; } if (g_dispatchers[dispatcherId] != NULL) { - HDF_LOGE("%s:DispatcherId conflict!ID=%d", __func__, dispatcherId); + HDF_LOGE("%s:DispatcherId conflict!ID=%u", __func__, dispatcherId); errCode = ME_ERROR_DISPATCHERID_CONFLICT; } else { g_dispatchers[dispatcherId] = dispatcher; @@ -154,7 +154,7 @@ ErrorCode AddDispatcher(DispatcherConfig *config) if (dispatcher->Start != NULL) { errCode = dispatcher->Start(dispatcher); if (errCode != ME_SUCCESS) { - HDF_LOGE("%s:Start dispatcher %d failed!errCode=%d", __func__, config->dispatcherId, errCode); + HDF_LOGE("%s:Start dispatcher %u failed!errCode=%d", __func__, config->dispatcherId, errCode); break; } } @@ -242,7 +242,7 @@ static ErrorCode DoRegistService(const NodeId nodeId, const DispatcherId dispatc return ME_ERROR_WRONG_STATUS; } - HDF_LOGW("%s:Regist service Node:%d;Dispatcher:%d;Service:%d", __func__, nodeId, dispatcherId, + HDF_LOGW("%s:Register service Node:%d;Dispatcher:%u;Service:%u", __func__, nodeId, dispatcherId, remoteService->serviceId); if (g_servicesIndex[remoteService->serviceId].remoteService != NULL) { @@ -263,7 +263,7 @@ static ErrorCode RegistServiceInner(const NodeId nodeId, const DispatcherId disp } if (mapper->serviceId >= MESSAGE_ENGINE_MAX_SERVICE) { - HDF_LOGE("%s:serviceId exceed max value! ServiceId=%d", __func__, mapper->serviceId); + HDF_LOGE("%s:serviceId exceed max value! ServiceId=%u", __func__, mapper->serviceId); return ME_ERROR_PARA_WRONG; } HDF_STATUS status = OsalMutexTimedLock(&g_routerMutex, HDF_WAIT_FOREVER); @@ -275,6 +275,7 @@ static ErrorCode RegistServiceInner(const NodeId nodeId, const DispatcherId disp MessageNode *node = RefMessageNode(nodeId, false); if (node == NULL) { HDF_LOGE("%s:Node not found!", __func__); + OsalMutexUnlock(&g_routerMutex); return ME_ERROR_NO_SUCH_NODE; } RemoteService *remoteService = NULL; @@ -556,7 +557,7 @@ static ErrorCode DoStartMessageRouter(uint8_t nodesConfig) return ME_ERROR_MUTI_INIT_NOT_ALLOWED; } - for (i = 0; i < UINT8_MAX && i < MESSAGE_ENGINE_MAX_SERVICE; i++) { + for (i = 0; i < MESSAGE_ENGINE_MAX_SERVICE; i++) { g_servicesIndex[i].remoteService = NULL; g_servicesIndex[i].nodeIndex = NO_SUCH_NODE_INDEX; g_servicesIndex[i].dispatcherId = BAD_DISPATCHER_ID; @@ -599,10 +600,10 @@ ErrorCode EnableDefaultDispatcher(void) .queueSize = DEFAULT_DISPATCHER_QUEUE_SIZE, .priorityLevelCount = DEFAULT_DISPATCHER_PRIORITY_COUNT }; - HDF_LOGI("Regist default dispatcher..."); + HDF_LOGI("Register default dispatcher..."); ErrorCode errCode = AddDispatcher(&config); if (errCode != ME_SUCCESS) { - HDF_LOGE("Regist default dispatcher failed!ret=%d", errCode); + HDF_LOGE("Register default dispatcher failed!ret=%d", errCode); } return errCode; } diff --git a/model/network/wifi/platform/src/message/nodes/local_node.c b/model/network/wifi/platform/src/message/nodes/local_node.c index 5ac55373b843b97bd6a411c144cb25361dccd345..b5b8c89a114ce8d8f986590e1a1fc5aabfd7f385 100644 --- a/model/network/wifi/platform/src/message/nodes/local_node.c +++ b/model/network/wifi/platform/src/message/nodes/local_node.c @@ -67,18 +67,19 @@ static void HandleResponseMessage(const RemoteService *service, MessageContext * } ReleaseMessageContext(context); } else { - HDF_LOGE("%s:Response type not supported!type=%d", __func__, context->requestType); + HDF_LOGE("%s:Response type not supported!type=%u", __func__, context->requestType); } } ErrorCode SendMessageLocalNode(const RemoteService *service, MessageContext *context) { + uint8_t pri = HIGHEST_PRIORITY; if (service == NULL || context == NULL) { HDF_LOGE("%s:Input is NULL!", __func__); return ME_ERROR_NULL_PTR; } - if (!context->corssNode && context->requestType == MESSAGE_TYPE_SYNC_REQ) { + if (!context->crossNode && context->requestType == MESSAGE_TYPE_SYNC_REQ) { HandleRequestMessage(service, context); SetToResponse(context); return context->responseStatus; @@ -103,11 +104,9 @@ ErrorCode SendMessageLocalNode(const RemoteService *service, MessageContext *con return ME_ERROR_NO_SUCH_COMMAND; } - uint8_t pri = localService->mapper->messages[context->commandId].pri; - return localService->dispatcher->AppendMessage(localService->dispatcher, pri, context); - } else { - return localService->dispatcher->AppendMessage(localService->dispatcher, HIGHEST_PRIORITY, context); + pri = localService->mapper->messages[context->commandId].pri; } + return localService->dispatcher->AppendMessage(localService->dispatcher, pri, context); } } diff --git a/model/network/wifi/platform/src/message/sidecar.c b/model/network/wifi/platform/src/message/sidecar.c index b49e9abdcb9ad332b9f98448f24e9dbc4ade5ffc..dc8692e93507f1f2ac8fbe159aa901a64fd74e6e 100644 --- a/model/network/wifi/platform/src/message/sidecar.c +++ b/model/network/wifi/platform/src/message/sidecar.c @@ -50,7 +50,7 @@ static MessageContext *CreateMessageContext(ServiceId sender, ServiceId receiver context->senderId = sender; context->receiverId = receiver; context->reqData = sendData; - context->corssNode = false; + context->crossNode = false; return context; } @@ -260,7 +260,7 @@ Service *InitService(struct ServiceDef *def, const ServiceCfg *cfg) service->privateData = NULL; OsalMemFree(service); service = NULL; - HDF_LOGE("Regist service failed!serviceId=%d,ret=%d", def->serviceId, errCode); + HDF_LOGE("Register service failed!serviceId=%d,ret=%d", def->serviceId, errCode); return NULL; } return service; diff --git a/model/sensor/driver/chipset/accel/accel_bmi160.c b/model/sensor/driver/chipset/accel/accel_bmi160.c index f82c0129092b33ca8880d1263d59238c29b3ab71..382c60f9eab82a2ca59e2015afb47e470c415823 100644 --- a/model/sensor/driver/chipset/accel/accel_bmi160.c +++ b/model/sensor/driver/chipset/accel/accel_bmi160.c @@ -25,12 +25,12 @@ static int32_t ReadBmi160RawData(struct SensorCfgData *data, struct AccelData *r OsalTimespec time; (void)memset_s(&time, sizeof(time), 0, sizeof(time)); - (void)memset_s(®, sizeof(reg), 0, sizeof(reg)); - + (void)memset_s(reg, sizeof(reg), 0, sizeof(reg)); CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM); + if (OsalGetTime(&time) != HDF_SUCCESS) { - HDF_LOGE("%s: Get accel system time failed", __func__); + HDF_LOGE("%s: Get time failed", __func__); return HDF_FAILURE; } *timestamp = time.sec * SENSOR_SECOND_CONVERT_NANOSECOND + time.usec * SENSOR_CONVERT_UNIT; /* unit nanosecond */ @@ -120,7 +120,7 @@ static int32_t InitAccelPreConfig(void) return HDF_FAILURE; } if (SetSensorPinMux(SENSOR_I2C6_CLK_REG_ADDR, SENSOR_ADDR_WIDTH_4_BYTE, SENSOR_I2C_REG_CFG) != HDF_SUCCESS) { - HDF_LOGE("%s: ClK write mux pin failed", __func__); + HDF_LOGE("%s: Clk write mux pin failed", __func__); return HDF_FAILURE; } diff --git a/model/sensor/driver/common/src/sensor_common.c b/model/sensor/driver/common/src/sensor_common.c index 411bf25c3de5abf86f6aa5d4530f5cb40a9ee70d..a48719f978f46a0398a696f0c3e58c3115241d0b 100644 --- a/model/sensor/driver/common/src/sensor_common.c +++ b/model/sensor/driver/common/src/sensor_common.c @@ -36,7 +36,6 @@ int32_t ReadSensor(struct SensorBusCfg *busCfg, uint16_t regAddr, uint8_t *data, if (busCfg->busType == SENSOR_BUS_I2C) { CHECK_NULL_PTR_RETURN_VALUE(busCfg->i2cCfg.handle, HDF_FAILURE); - (void)memset_s(msg, sizeof(msg), 0, sizeof(msg)); msg[I2C_READ_MSG_ADDR_IDX].addr = busCfg->i2cCfg.devAddr; msg[I2C_READ_MSG_ADDR_IDX].flags = 0; diff --git a/model/sensor/driver/common/src/sensor_device_common.c b/model/sensor/driver/common/src/sensor_device_common.c index da1e2e85b178b850bfe1121d328bd2ab4aba317c..08fc9f4e54b9ff307fb50ef40f65a9d732f07f8b 100644 --- a/model/sensor/driver/common/src/sensor_device_common.c +++ b/model/sensor/driver/common/src/sensor_device_common.c @@ -83,6 +83,8 @@ static int32_t SensorOpsReadCheck(struct SensorBusCfg *busCfg, struct SensorRegC uint16_t busMask = 0xffff; int32_t ret; + CHECK_NULL_PTR_RETURN_VALUE(busCfg, HDF_FAILURE); + if (busCfg->busType == SENSOR_BUS_I2C) { ret = ReadSensor(busCfg, cfgItem->regAddr, (uint8_t *)&value, sizeof(value)); CHECK_PARSER_RESULT_RETURN_VALUE(ret, "read i2c reg"); @@ -123,6 +125,7 @@ int32_t SetSensorRegCfgArray(struct SensorBusCfg *busCfg, const struct SensorReg CHECK_NULL_PTR_RETURN_VALUE(group->regCfgItem, HDF_FAILURE); count = sizeof(g_doOpsCall) / sizeof(g_doOpsCall[0]); + while (num < group->itemNum) { cfgItem = (group->regCfgItem + num); if (cfgItem->opsType >= count) { diff --git a/model/sensor/driver/common/src/sensor_parser.c b/model/sensor/driver/common/src/sensor_parser.c index 96392aca84d39f0636a6cfaebd04b6454f503aef..0030fc487f703e10efdc76bab6469909b03945b7 100644 --- a/model/sensor/driver/common/src/sensor_parser.c +++ b/model/sensor/driver/common/src/sensor_parser.c @@ -22,22 +22,18 @@ static char *g_sensorRegGroupName[SENSOR_GROUP_MAX] = { static uint32_t GetSensorRegGroupNameIndex(const char *name) { - uint32_t index = 0xFF; + uint32_t index; if (name == NULL) { - return index; + return SENSOR_GROUP_MAX; } for (index = 0; index < SENSOR_GROUP_MAX; ++index) { - if (strcmp(name, g_sensorRegGroupName[index]) == 0) { + if ((g_sensorRegGroupName[index] != NULL) && (strcmp(name, g_sensorRegGroupName[index]) == 0)) { break; } } - if (index == SENSOR_GROUP_MAX) { - index = 0xFF; - } - return index; } @@ -73,6 +69,11 @@ static int32_t ParseSensorRegItem(struct DeviceResourceIface *parser, const stru CHECK_NULL_PTR_RETURN_VALUE(groupName, HDF_ERR_INVALID_PARAM); int32_t num = parser->GetElemNum(regNode, groupName); + if (num <= 0 || num > SENSOR_CONFIG_MAX_ITEM) { + HDF_LOGE("%s: parser %s element num failed", __func__, groupName); + return HDF_SUCCESS; + } + uint16_t *buf = (uint16_t *)OsalMemCalloc(sizeof(uint16_t) * num); CHECK_NULL_PTR_RETURN_VALUE(buf, HDF_ERR_MALLOC_FAIL); @@ -196,7 +197,6 @@ int32_t GetSensorBusHandle(struct SensorBusCfg *busCfg) if (busCfg->busType == SENSOR_BUS_I2C) { int16_t busNum = busCfg->i2cCfg.busNum; busCfg->i2cCfg.handle = I2cOpen(busNum); - if (busCfg->i2cCfg.handle == NULL) { HDF_LOGE("%s: sensor i2c Handle invalid", __func__); return HDF_FAILURE; @@ -246,7 +246,7 @@ int32_t DetectSensorDevice(struct SensorCfgData *config) } if (value != chipIdValue) { - HDF_LOGE("%s: sensor chip[0x%x] id [0x%x] detect value[%d]", __func__, chipIdReg, chipIdValue, value); + HDF_LOGE("%s: sensor chip[0x%x] id [0x%x] detect value[%u]", __func__, chipIdReg, chipIdValue, value); (void)ReleaseSensorBusHandle(&config->busCfg); return HDF_FAILURE; } diff --git a/model/sensor/driver/include/sensor_driver_type.h b/model/sensor/driver/include/sensor_driver_type.h index ef2d3c70a22624516564bf4b45496487f5c1520c..dfbe3c39936efc996ae505c78935d101165255fb 100644 --- a/model/sensor/driver/include/sensor_driver_type.h +++ b/model/sensor/driver/include/sensor_driver_type.h @@ -37,7 +37,7 @@ enum SensorWorkMode { }; enum SensorTag { - SENSOR_TAG_NONE = 0, /**< No sensor type for sensor test*/ + SENSOR_TAG_NONE = 0, /**< No sensor type for sensor test */ SENSOR_TAG_ACCELEROMETER = 1, /**< Acceleration sensor */ SENSOR_TAG_GYROSCOPE = 2, /**< Gyroscope sensor */ SENSOR_TAG_PHOTOPLETHYSMOGRAPH = 3, /**< Photoplethysmography sensor */