提交 69512a37 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

fix a bug. sizeof operator in C/C++ never returns 0, so, an empty struct's size is 1!

上级 56098b56
...@@ -311,7 +311,7 @@ void MainDialog::on_pushButton_CrTime_clicked() ...@@ -311,7 +311,7 @@ void MainDialog::on_pushButton_CrTime_clicked()
} }
saveIni(); saveIni();
quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header)
+sizeof(stMsg_HostTimeCorrectReq); /*+sizeof(stMsg_HostTimeCorrectReq)*/;
QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0);
char * ptr = array.data(); char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
...@@ -405,7 +405,7 @@ void MainDialog::on_pushButton_box_download_uid_clicked() ...@@ -405,7 +405,7 @@ void MainDialog::on_pushButton_box_download_uid_clicked()
} }
saveIni(); saveIni();
quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header)
+sizeof(stMsg_DownloadUserListReq); /*+sizeof(stMsg_DownloadUserListReq)*/;
QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0);
char * ptr = array.data(); char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
...@@ -446,7 +446,7 @@ void MainDialog::on_pushButton_client_downHost_clicked() ...@@ -446,7 +446,7 @@ void MainDialog::on_pushButton_client_downHost_clicked()
} }
saveIni(); saveIni();
quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header) quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header)
+sizeof(stMsg_GetHostListReq); /*+sizeof(stMsg_GetHostListReq)*/;
QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0); QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0);
char * ptr = array.data(); char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr; SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
......
...@@ -346,7 +346,7 @@ namespace SmartLink{ ...@@ -346,7 +346,7 @@ namespace SmartLink{
if (m_currentMessageSize!= if (m_currentMessageSize!=
sizeof(SMARTLINK_MSG) - 1 sizeof(SMARTLINK_MSG) - 1
+ sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) + 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.")); emit evt_Message(tr("Broken Message stMsg_HostRegistReq, size not correct."));
res = false; res = false;
...@@ -376,7 +376,7 @@ namespace SmartLink{ ...@@ -376,7 +376,7 @@ namespace SmartLink{
if (m_currentMessageSize!= if (m_currentMessageSize!=
sizeof(SMARTLINK_MSG) - 1 sizeof(SMARTLINK_MSG) - 1
+ sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) + 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.")); emit evt_Message(tr("Broken Message stMsg_DownloadUserListReq, size not correct."));
res = false; res = false;
...@@ -406,7 +406,7 @@ namespace SmartLink{ ...@@ -406,7 +406,7 @@ namespace SmartLink{
if (m_currentMessageSize!= if (m_currentMessageSize!=
sizeof(SMARTLINK_MSG) - 1 sizeof(SMARTLINK_MSG) - 1
+ sizeof (SMARTLINK_MSG_APP::tag_app_layer_header) + 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.")); emit evt_Message(tr("Broken Message stMsg_GetHostListReq, size not correct."));
res = false; res = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册