Commit 26ec3a50 authored by Don Gagne's avatar Don Gagne

Fix Linux Release build compiler warning

parent af8af613
...@@ -139,7 +139,7 @@ void MockMavlinkFileServer::_openCommand(QGCUASFileManager::Request* request, ui ...@@ -139,7 +139,7 @@ void MockMavlinkFileServer::_openCommand(QGCUASFileManager::Request* request, ui
// Data contains file length // Data contains file length
response.hdr.size = sizeof(uint32_t); response.hdr.size = sizeof(uint32_t);
*((uint32_t*)response.data) = _readFileLength; response.openFileLength = _readFileLength;
_emitResponse(&response, outgoingSeqNumber); _emitResponse(&response, outgoingSeqNumber);
} }
......
...@@ -107,8 +107,7 @@ void QGCUASFileManager::_openAckResponse(Request* openAck) ...@@ -107,8 +107,7 @@ void QGCUASFileManager::_openAckResponse(Request* openAck)
// File length comes back in data // File length comes back in data
Q_ASSERT(openAck->hdr.size == sizeof(uint32_t)); Q_ASSERT(openAck->hdr.size == sizeof(uint32_t));
uint32_t fileLength = *((uint32_t*)&openAck->data[0]); emit openFileLength(openAck->openFileLength);
emit openFileLength(fileLength);
_readOffset = 0; // Start reading at beginning of file _readOffset = 0; // Start reading at beginning of file
_readFileAccumulator.clear(); // Start with an empty file _readFileAccumulator.clear(); // Start with an empty file
......
...@@ -71,9 +71,16 @@ protected: ...@@ -71,9 +71,16 @@ protected:
struct Request struct Request
{ {
struct RequestHeader hdr; struct RequestHeader hdr;
// The entire Request must fit into the data member of the mavlink_encapsulated_data_t structure. We use as many leftover bytes
// after we use up space for the RequestHeader for the data portion of the Request. // We use a union here instead of just casting (uint32_t)&data[0] to not break strict aliasing rules
uint8_t data[sizeof(((mavlink_encapsulated_data_t*)0)->data) - sizeof(RequestHeader)]; union {
// The entire Request must fit into the data member of the mavlink_encapsulated_data_t structure. We use as many leftover bytes
// after we use up space for the RequestHeader for the data portion of the Request.
uint8_t data[sizeof(((mavlink_encapsulated_data_t*)0)->data) - sizeof(RequestHeader)];
// File length returned by Open command
uint32_t openFileLength;
};
}; };
enum Opcode enum Opcode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment