From 54c8e3b26b50d66a5adc95a4f7295e7c2f19d2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 3 Mar 2017 09:15:06 +0100 Subject: [PATCH] commander: fix excessive orb_advertise calls for vehicle_status_flags vehicle_status_flags_pub passed to publish_status_flags() was always null, thus orb_advertise() was called each time. Note that it did not produce a memory leak. --- src/modules/commander/commander.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 16228d72ef..ac76323a75 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -298,11 +298,11 @@ static void commander_set_home_position(orb_advert_t &homePub, home_position_s & */ void *commander_low_prio_loop(void *arg); -void answer_command(struct vehicle_command_s &cmd, unsigned result, +static void answer_command(struct vehicle_command_s &cmd, unsigned result, orb_advert_t &command_ack_pub, vehicle_command_ack_s &command_ack); /* publish vehicle status flags from the global variable status_flags*/ -void publish_status_flags(orb_advert_t vehicle_status_flags_pub); +static void publish_status_flags(orb_advert_t &vehicle_status_flags_pub); /** * check whether autostart ID is in the reserved range for HIL setups @@ -4295,7 +4295,7 @@ void *commander_low_prio_loop(void *arg) return nullptr; } -void publish_status_flags(orb_advert_t vehicle_status_flags_pub){ +void publish_status_flags(orb_advert_t &vehicle_status_flags_pub) { struct vehicle_status_flags_s v_flags; memset(&v_flags, 0, sizeof(v_flags)); /* set condition status flags */ @@ -4412,7 +4412,7 @@ void publish_status_flags(orb_advert_t vehicle_status_flags_pub){ /* publish vehicle_status_flags */ if (vehicle_status_flags_pub != nullptr) { orb_publish(ORB_ID(vehicle_status_flags), vehicle_status_flags_pub, &v_flags); - }else{ + } else { vehicle_status_flags_pub = orb_advertise(ORB_ID(vehicle_status_flags), &v_flags); } }