From 35b673e538598259a0987232fc0f7a712863e7fd Mon Sep 17 00:00:00 2001 From: liangliang_ma Date: Sat, 3 Sep 2022 10:20:58 +0000 Subject: [PATCH] modify complie warnings. Signed-off-by: liangliang_ma Change-Id: I7562a2a346e4d2a6250012688b4f9fd23839abea --- core/authentication/src/auth_connection.c | 34 ++++++++++++------- core/authentication/src/auth_hichain.c | 4 ++- core/authentication/src/auth_tcp_connection.c | 2 +- .../lnn/net_builder/src/lnn_connection_fsm.c | 2 +- .../lnn/net_builder/src/lnn_net_builder.c | 2 +- .../proxy/src/softbus_proxychannel_control.c | 2 +- .../proxy/src/softbus_proxychannel_message.c | 2 +- .../src/trans_tcp_direct_listener.c | 2 +- .../tcp_direct/src/trans_tcp_direct_message.c | 2 +- 9 files changed, 32 insertions(+), 20 deletions(-) diff --git a/core/authentication/src/auth_connection.c b/core/authentication/src/auth_connection.c index 3ebbc01b7..dc0b8c865 100644 --- a/core/authentication/src/auth_connection.c +++ b/core/authentication/src/auth_connection.c @@ -300,7 +300,8 @@ static void OnWiFiConnected(int32_t fd, bool isClient) static void OnWiFiDisconnected(int32_t fd) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_INFO, "OnWiFiDisconnected: fd=%d.", fd); - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; + (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); connInfo.type = AUTH_LINK_TYPE_WIFI; NotifyDisconnected(GenConnId(connInfo.type, fd), &connInfo); } @@ -310,7 +311,8 @@ static void OnWiFiDataReceived(int32_t fd, const AuthDataHead *head, const uint8 CHECK_NULL_PTR_RETURN_VOID(head); CHECK_NULL_PTR_RETURN_VOID(data); bool fromServer = false; - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; + (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); if (SocketGetConnInfo(fd, &connInfo, &fromServer) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "get connInfo fail, fd=%d.", fd); return; @@ -338,7 +340,8 @@ static void OnCommDisconnected(uint32_t connectionId, const ConnectionInfo *info { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_INFO, "OnCommDisconnected: connectionId=%u.", connectionId); CHECK_NULL_PTR_RETURN_VOID(info); - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; + (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); (void)ConvertToAuthConnInfo(info, &connInfo); NotifyDisconnected(GenConnId(connInfo.type, connectionId), &connInfo); } @@ -364,7 +367,8 @@ static void OnCommDataReceived(uint32_t connectionId, ConnModule moduleId, int64 bool fromServer = ((seq % SEQ_INTERVAL) != 0); SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_INFO, "RecvCommData: connectionId=%u, module=%d, seq=%" PRId64 ", len=%d, from=%s.", connectionId, moduleId, seq, len, GetAuthSideStr(fromServer)); - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; + (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); if (GetConnInfoByConnectionId(connectionId, &connInfo) != SOFTBUS_OK) { return; } @@ -389,10 +393,11 @@ static int32_t InitCommConn(void) static void OnCommConnectSucc(uint32_t requestId, uint32_t connectionId, const ConnectionInfo *info) { - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_INFO, "OnCommConnectSucc: requestId=%u, connectionId=%u.", requestId, connectionId); CHECK_NULL_PTR_RETURN_VOID(info); + (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); (void)ConvertToAuthConnInfo(info, &connInfo); RemoveConnConnectTimeout(requestId); NotifyClientConnected(requestId, GenConnId(connInfo.type, connectionId), SOFTBUS_OK, &connInfo); @@ -408,7 +413,8 @@ static void OnCommConnectFail(uint32_t requestId, int32_t reason) static int32_t ConnectCommDevice(const AuthConnInfo *info, uint32_t requestId, ConnSideType sideType) { - ConnectOption option = {0}; + ConnectOption option; + (void)memset_s(&option, sizeof(ConnectOption), 0, sizeof(ConnectOption)); int32_t ret = ConvertToConnectOption(info, &option); if (ret != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "ConvertToConnectOption fail(=%d).", ret); @@ -487,17 +493,19 @@ void AuthConnDeinit(void) int32_t ConnectAuthDevice(uint32_t requestId, const AuthConnInfo *connInfo, ConnSideType sideType) { int32_t ret; - ConnCmdInfo info = {0}; CHECK_NULL_PTR_RETURN_VALUE(connInfo, SOFTBUS_INVALID_PARAM); SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_INFO, "ConnectDevice: requestId=%u, connType=%d, sideType=%d.", requestId, connInfo->type, sideType); PostConnConnectTimeout(requestId); switch (connInfo->type) { - case AUTH_LINK_TYPE_WIFI: - info.requestId = requestId, - info.connInfo = *connInfo, + case AUTH_LINK_TYPE_WIFI: { + ConnCmdInfo info = { + .requestId = requestId, + .connInfo = *connInfo + }; ret = PostAuthEvent(EVENT_CONNECT_CMD, HandleConnConnectCmd, &info, sizeof(ConnCmdInfo), 0); break; + } case AUTH_LINK_TYPE_BLE: case AUTH_LINK_TYPE_BR: case AUTH_LINK_TYPE_P2P: @@ -558,7 +566,8 @@ ConnSideType GetConnSideType(uint64_t connId) "WiFi not supported, " CONN_INFO, CONN_DATA(connId)); return CONN_SIDE_ANY; } - ConnectionInfo info = {0}; + ConnectionInfo info; + (void)memset_s(&info, sizeof(ConnectionInfo), 0, sizeof(ConnectionInfo)); if (ConnGetConnectionInfo(GetConnId(connId), &info)) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "ConnGetConnectionInfo fail, " CONN_INFO, CONN_DATA(connId)); @@ -573,8 +582,9 @@ ConnSideType GetConnSideType(uint64_t connId) bool CheckActiveAuthConnection(const AuthConnInfo *connInfo) { + ConnectOption connOpt; CHECK_NULL_PTR_RETURN_VALUE(connInfo, false); - ConnectOption connOpt = {0}; + (void)memset_s(&connOpt, sizeof(ConnectOption), 0, sizeof(ConnectOption)); if (ConvertToConnectOption(connInfo, &connOpt) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "convert to connect option fail, connType=%d.", connInfo->type); diff --git a/core/authentication/src/auth_hichain.c b/core/authentication/src/auth_hichain.c index eccdad420..fec954076 100644 --- a/core/authentication/src/auth_hichain.c +++ b/core/authentication/src/auth_hichain.c @@ -156,11 +156,13 @@ static int32_t ParseGroupInfo(const char *groupInfoStr, GroupInfo *groupInfo) cJSON_Delete(msg); return SOFTBUS_ERR; } - if (!GetJsonObjectNumberItem(msg, FIELD_GROUP_TYPE, &groupInfo->groupType)) { + int32_t groupType = 0; + if (!GetJsonObjectNumberItem(msg, FIELD_GROUP_TYPE, &groupType)) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "get FIELD_GROUP_TYPE fail."); cJSON_Delete(msg); return SOFTBUS_ERR; } + groupInfo->groupType = (GroupType)groupType; cJSON_Delete(msg); return SOFTBUS_OK; } diff --git a/core/authentication/src/auth_tcp_connection.c b/core/authentication/src/auth_tcp_connection.c index 451a4a4ff..f98fd1db5 100644 --- a/core/authentication/src/auth_tcp_connection.c +++ b/core/authentication/src/auth_tcp_connection.c @@ -355,7 +355,7 @@ int32_t SocketConnectDevice(const char *ip, int32_t port, bool isBlockMode) SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "ConnOpenClientSocket fail."); return AUTH_INVALID_FD; } - int32_t triggerMode = isBlockMode ? READ_TRIGGER : WRITE_TRIGGER; + TriggerType triggerMode = isBlockMode ? READ_TRIGGER : WRITE_TRIGGER; if (AddTrigger(AUTH, fd, triggerMode) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "AddTrigger fail."); ConnShutdownSocket(fd); diff --git a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c index 0899af493..b4ad3e67e 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c +++ b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c @@ -324,7 +324,7 @@ static void TryCancelJoinProcedure(LnnConnectionFsm *connFsm) static int32_t OnJoinLNN(LnnConnectionFsm *connFsm) { int32_t rc; - AuthConnInfo authConn = {0}; + AuthConnInfo authConn; LnnConntionInfo *connInfo = &connFsm->connInfo; if (CheckDeadFlag(connFsm, true)) { diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c index 29bd831e3..6ca21756e 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c @@ -1154,7 +1154,7 @@ static NodeInfo *DupNodeInfo(const NodeInfo *nodeInfo) static void OnDeviceVerifyPass(int64_t authId, const NodeInfo *info) { - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; DeviceVerifyPassMsgPara *para = NULL; SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "verify passed passively, authId=%" PRId64, authId); if (AuthGetConnInfo(authId, &connInfo) != SOFTBUS_OK) { diff --git a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_control.c b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_control.c index c9738a460..00e45d886 100644 --- a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_control.c +++ b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_control.c @@ -56,7 +56,7 @@ static int32_t SetCipherOfHandshakeMsg(uint32_t channelId, uint8_t *cipher) SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get authId fail"); return SOFTBUS_ERR; } - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; if (AuthGetConnInfo(authId, &connInfo) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get auth connInfo fail"); return SOFTBUS_ERR; diff --git a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_message.c b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_message.c index a7eedeb5d..0e3b47764 100644 --- a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_message.c +++ b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_message.c @@ -119,7 +119,7 @@ static int32_t TransProxyGetAuthConnInfo(uint32_t connId, AuthConnInfo *connInfo static int64_t GetAuthIdByHandshakeMsg(uint32_t connId, uint8_t cipher) { - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; if (TransProxyGetAuthConnInfo(connId, &connInfo) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get connInfo fail connId[%d]", connId); return AUTH_INVALID_ID; diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c index 57f6afef6..509662038 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c @@ -48,7 +48,7 @@ uint32_t SwitchAuthLinkTypeToFlagType(AuthLinkType type) int32_t GetCipherFlagByAuthId(int64_t authId, uint32_t *flag, bool *isAuthServer) { - AuthConnInfo info = {0}; + AuthConnInfo info; if (AuthGetServerSide(authId, isAuthServer) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get auth server side fail %" PRId64, authId); return SOFTBUS_ERR; diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c index 9f329a860..797f01b5b 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c @@ -481,7 +481,7 @@ static int64_t GetAuthIdByChannelInfo(int32_t channelId, uint64_t seq, uint32_t bool fromAuthServer = ((seq & AUTH_CONN_SERVER_SIDE) != 0); char p2pMac[P2P_MAC_LEN] = {0}; if (P2pLinkGetPeerMacByPeerIp(appInfo.peerData.addr, p2pMac, sizeof(p2pMac)) != SOFTBUS_OK) { - AuthConnInfo connInfo = {0}; + AuthConnInfo connInfo; connInfo.type = AUTH_LINK_TYPE_WIFI; if (strcpy_s(connInfo.info.ipInfo.ip, IP_LEN, appInfo.peerData.addr) != EOK) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "copy ip addr fail");