From a2ff53b0187f0cfe7a9e2fae5cdc354de6b6e348 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 7 Dec 2020 14:56:30 +1300 Subject: [PATCH] mavlink: remove typedef of anonymous struct Clang doesn't seem to like these. --- src/modules/mavlink/mavlink_command_sender.cpp | 8 ++++---- src/modules/mavlink/mavlink_command_sender.h | 6 +++--- src/modules/mavlink/timestamped_list.h | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/modules/mavlink/mavlink_command_sender.cpp b/src/modules/mavlink/mavlink_command_sender.cpp index c8fd0d1a3e..b076115e8e 100644 --- a/src/modules/mavlink/mavlink_command_sender.cpp +++ b/src/modules/mavlink/mavlink_command_sender.cpp @@ -87,7 +87,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s bool already_existing = false; _commands.reset_to_start(); - while (command_item_t *item = _commands.get_next()) { + while (command_item_s *item = _commands.get_next()) { if (item->timestamp_us == command.timestamp) { // We should activate the channel by setting num_sent_per_channel from -1 to 0. @@ -99,7 +99,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s if (!already_existing) { - command_item_t new_item; + command_item_s new_item; new_item.command = msg; new_item.timestamp_us = command.timestamp; new_item.num_sent_per_channel[channel] = 0; @@ -120,7 +120,7 @@ void MavlinkCommandSender::handle_mavlink_command_ack(const mavlink_command_ack_ _commands.reset_to_start(); - while (command_item_t *item = _commands.get_next()) { + while (command_item_s *item = _commands.get_next()) { // Check if the incoming ack matches any of the commands that we have sent. if (item->command.command == ack.command && (item->command.target_system == 0 || from_sysid == item->command.target_system) && @@ -140,7 +140,7 @@ void MavlinkCommandSender::check_timeout(mavlink_channel_t channel) _commands.reset_to_start(); - while (command_item_t *item = _commands.get_next()) { + while (command_item_s *item = _commands.get_next()) { if (hrt_elapsed_time(&item->last_time_sent_us) <= TIMEOUT_US) { // We keep waiting for the timeout. continue; diff --git a/src/modules/mavlink/mavlink_command_sender.h b/src/modules/mavlink/mavlink_command_sender.h index 46b5ca88dc..2454055802 100644 --- a/src/modules/mavlink/mavlink_command_sender.h +++ b/src/modules/mavlink/mavlink_command_sender.h @@ -105,14 +105,14 @@ private: // There are MAVLINK_COMM_0 to MAVLINK_COMM_3, so it should be 4. static const unsigned MAX_MAVLINK_CHANNEL = 4; - typedef struct { + struct command_item_s { mavlink_command_long_t command = {}; hrt_abstime timestamp_us = 0; hrt_abstime last_time_sent_us = 0; int8_t num_sent_per_channel[MAX_MAVLINK_CHANNEL] = {-1, -1, -1, -1}; // -1: channel did not request this command to be sent, -2: channel got an ack for this command - } command_item_t; + }; - TimestampedList _commands{3}; + TimestampedList _commands{3}; bool _debug_enabled = false; static constexpr uint8_t RETRIES = 3; diff --git a/src/modules/mavlink/timestamped_list.h b/src/modules/mavlink/timestamped_list.h index 4bd8005e66..67f1df2a5d 100644 --- a/src/modules/mavlink/timestamped_list.h +++ b/src/modules/mavlink/timestamped_list.h @@ -55,7 +55,7 @@ class TimestampedList public: TimestampedList(int num_items) { - _list = new item_t[num_items]; + _list = new item_s[num_items]; _list_len = num_items; } @@ -148,12 +148,12 @@ public: TimestampedList operator=(const TimestampedList &) = delete; private: - typedef struct { + struct item_s { hrt_abstime timestamp_us = 0; // 0 signals inactive. T value; - } item_t; + }; - item_t *_list = nullptr; + item_s *_list = nullptr; int _list_len = 0; int _current_i = -1; };