From 69512a37f15b3107e57997643353003ff142bded Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Mon, 14 Apr 2014 23:41:46 +0800 Subject: [PATCH] fix a bug. sizeof operator in C/C++ never returns 0, so, an empty struct's size is 1! --- FunctionalClientTest/maindialog.cpp | 6 +++--- ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/FunctionalClientTest/maindialog.cpp b/FunctionalClientTest/maindialog.cpp index e24b550..d7471f8 100644 --- a/FunctionalClientTest/maindialog.cpp +++ b/FunctionalClientTest/maindialog.cpp @@ -311,7 +311,7 @@ void MainDialog::on_pushButton_CrTime_clicked() } saveIni(); quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) - +sizeof(stMsg_HostTimeCorrectReq); + /*+sizeof(stMsg_HostTimeCorrectReq)*/; QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); char * ptr = array.data(); SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; @@ -405,7 +405,7 @@ void MainDialog::on_pushButton_box_download_uid_clicked() } saveIni(); quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) - +sizeof(stMsg_DownloadUserListReq); + /*+sizeof(stMsg_DownloadUserListReq)*/; QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); char * ptr = array.data(); SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; @@ -446,7 +446,7 @@ void MainDialog::on_pushButton_client_downHost_clicked() } saveIni(); quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) - +sizeof(stMsg_GetHostListReq); + /*+sizeof(stMsg_GetHostListReq)*/; QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); char * ptr = array.data(); SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; diff --git a/ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp b/ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp index 6b08a91..f73c4c1 100644 --- a/ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp +++ b/ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp @@ -346,7 +346,7 @@ namespace SmartLink{ if (m_currentMessageSize!= sizeof(SMARTLINK_MSG) - 1 + sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) - + sizeof (stMsg_HostTimeCorrectReq)) + /*+ sizeof (stMsg_HostTimeCorrectReq)*/) { emit evt_Message(tr("Broken Message stMsg_HostRegistReq, size not correct.")); res = false; @@ -376,7 +376,7 @@ namespace SmartLink{ if (m_currentMessageSize!= sizeof(SMARTLINK_MSG) - 1 + sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) - + sizeof (stMsg_DownloadUserListReq)) + /*+ sizeof (stMsg_DownloadUserListReq)*/) { emit evt_Message(tr("Broken Message stMsg_DownloadUserListReq, size not correct.")); res = false; @@ -406,7 +406,7 @@ namespace SmartLink{ if (m_currentMessageSize!= sizeof(SMARTLINK_MSG) - 1 + sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) - + sizeof (stMsg_GetHostListReq)) + /*+ sizeof (stMsg_GetHostListReq)*/) { emit evt_Message(tr("Broken Message stMsg_GetHostListReq, size not correct.")); res = false; -- GitLab