Initialize all outgoing vehicle_command_ack_s and vehicle_command_s

This will initialize those structs with zero in all fields not set
and all fields set will only be change once to the final value not
wasting CPU time zeroing it.

This will guarantee that no non-unitialized structs will have
a trash value on from_external causing it to be sent to the
MAVLink channel without need it.
This commit is contained in:
José Roberto de Souza
2017-07-27 17:08:22 -07:00
committed by Lorenz Meier
parent 7c268f4fa1
commit 925efe990d
17 changed files with 267 additions and 261 deletions

View File

@@ -2001,10 +2001,11 @@ int Logger::remove_directory(const char *dir)
void Logger::ack_vehicle_command(orb_advert_t &vehicle_command_ack_pub, uint16_t command, uint32_t result)
{
vehicle_command_ack_s vehicle_command_ack;
vehicle_command_ack.timestamp = hrt_absolute_time();
vehicle_command_ack.command = command;
vehicle_command_ack.result = result;
vehicle_command_ack_s vehicle_command_ack = {
.timestamp = hrt_absolute_time(),
.command = command,
.result = (uint8_t)result
};
if (vehicle_command_ack_pub == nullptr) {
vehicle_command_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &vehicle_command_ack,