ArduCopter: use FALLTHROUGH define
When falling through on a case switch, allow to add an empty statement with the correct attribute to tell the compiler this behavior is intended.
This commit is contained in:
parent
927289aa64
commit
be402374ea
@ -748,14 +748,14 @@ bool Copter::verify_payload_place()
|
|||||||
// we're there; set loiter target
|
// we're there; set loiter target
|
||||||
auto_payload_place_start(wp_nav->get_wp_destination());
|
auto_payload_place_start(wp_nav->get_wp_destination());
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Calibrating_Hover_Start;
|
nav_payload_place.state = PayloadPlaceStateType_Calibrating_Hover_Start;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Calibrating_Hover_Start:
|
case PayloadPlaceStateType_Calibrating_Hover_Start:
|
||||||
// hover for 1 second to get an idea of what our hover
|
// hover for 1 second to get an idea of what our hover
|
||||||
// throttle looks like
|
// throttle looks like
|
||||||
debug("Calibrate start");
|
debug("Calibrate start");
|
||||||
nav_payload_place.hover_start_timestamp = now;
|
nav_payload_place.hover_start_timestamp = now;
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Calibrating_Hover;
|
nav_payload_place.state = PayloadPlaceStateType_Calibrating_Hover;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Calibrating_Hover: {
|
case PayloadPlaceStateType_Calibrating_Hover: {
|
||||||
if (now - nav_payload_place.hover_start_timestamp < hover_throttle_calibrate_time) {
|
if (now - nav_payload_place.hover_start_timestamp < hover_throttle_calibrate_time) {
|
||||||
// still calibrating...
|
// still calibrating...
|
||||||
@ -768,13 +768,13 @@ bool Copter::verify_payload_place()
|
|||||||
gcs().send_text(MAV_SEVERITY_INFO, "hover throttle delta: %f", static_cast<double>(hover_throttle_delta));
|
gcs().send_text(MAV_SEVERITY_INFO, "hover throttle delta: %f", static_cast<double>(hover_throttle_delta));
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Descending_Start;
|
nav_payload_place.state = PayloadPlaceStateType_Descending_Start;
|
||||||
}
|
}
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Descending_Start:
|
case PayloadPlaceStateType_Descending_Start:
|
||||||
nav_payload_place.descend_start_timestamp = now;
|
nav_payload_place.descend_start_timestamp = now;
|
||||||
nav_payload_place.descend_start_altitude = inertial_nav.get_altitude();
|
nav_payload_place.descend_start_altitude = inertial_nav.get_altitude();
|
||||||
nav_payload_place.descend_throttle_level = 0;
|
nav_payload_place.descend_throttle_level = 0;
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Descending;
|
nav_payload_place.state = PayloadPlaceStateType_Descending;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Descending:
|
case PayloadPlaceStateType_Descending:
|
||||||
// make sure we don't descend too far:
|
// make sure we don't descend too far:
|
||||||
debug("descended: %f cm (%f cm max)", (nav_payload_place.descend_start_altitude - inertial_nav.get_altitude()), nav_payload_place.descend_max);
|
debug("descended: %f cm (%f cm max)", (nav_payload_place.descend_start_altitude - inertial_nav.get_altitude()), nav_payload_place.descend_max);
|
||||||
@ -808,7 +808,7 @@ bool Copter::verify_payload_place()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Releasing_Start;
|
nav_payload_place.state = PayloadPlaceStateType_Releasing_Start;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Releasing_Start:
|
case PayloadPlaceStateType_Releasing_Start:
|
||||||
#if GRIPPER_ENABLED == ENABLED
|
#if GRIPPER_ENABLED == ENABLED
|
||||||
if (g2.gripper.valid()) {
|
if (g2.gripper.valid()) {
|
||||||
@ -823,7 +823,7 @@ bool Copter::verify_payload_place()
|
|||||||
gcs().send_text(MAV_SEVERITY_INFO, "Gripper code disabled");
|
gcs().send_text(MAV_SEVERITY_INFO, "Gripper code disabled");
|
||||||
#endif
|
#endif
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Releasing;
|
nav_payload_place.state = PayloadPlaceStateType_Releasing;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Releasing:
|
case PayloadPlaceStateType_Releasing:
|
||||||
#if GRIPPER_ENABLED == ENABLED
|
#if GRIPPER_ENABLED == ENABLED
|
||||||
if (g2.gripper.valid() && !g2.gripper.released()) {
|
if (g2.gripper.valid() && !g2.gripper.released()) {
|
||||||
@ -831,24 +831,24 @@ bool Copter::verify_payload_place()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Released;
|
nav_payload_place.state = PayloadPlaceStateType_Released;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Released: {
|
case PayloadPlaceStateType_Released: {
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Ascending_Start;
|
nav_payload_place.state = PayloadPlaceStateType_Ascending_Start;
|
||||||
}
|
}
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Ascending_Start: {
|
case PayloadPlaceStateType_Ascending_Start: {
|
||||||
Location_Class target_loc = inertial_nav.get_position();
|
Location_Class target_loc = inertial_nav.get_position();
|
||||||
target_loc.alt = nav_payload_place.descend_start_altitude;
|
target_loc.alt = nav_payload_place.descend_start_altitude;
|
||||||
auto_wp_start(target_loc);
|
auto_wp_start(target_loc);
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Ascending;
|
nav_payload_place.state = PayloadPlaceStateType_Ascending;
|
||||||
}
|
}
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Ascending:
|
case PayloadPlaceStateType_Ascending:
|
||||||
if (!wp_nav->reached_wp_destination()) {
|
if (!wp_nav->reached_wp_destination()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nav_payload_place.state = PayloadPlaceStateType_Done;
|
nav_payload_place.state = PayloadPlaceStateType_Done;
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
case PayloadPlaceStateType_Done:
|
case PayloadPlaceStateType_Done:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -183,7 +183,8 @@ bool Copter::autotune_init(bool ignore_checks)
|
|||||||
case AUTOTUNE_MODE_FAILED:
|
case AUTOTUNE_MODE_FAILED:
|
||||||
// autotune has been run but failed so reset state to uninitialized
|
// autotune has been run but failed so reset state to uninitialized
|
||||||
autotune_state.mode = AUTOTUNE_MODE_UNINITIALISED;
|
autotune_state.mode = AUTOTUNE_MODE_UNINITIALISED;
|
||||||
// no break to allow fall through to restart the tuning
|
// fall through to restart the tuning
|
||||||
|
FALLTHROUGH;
|
||||||
|
|
||||||
case AUTOTUNE_MODE_UNINITIALISED:
|
case AUTOTUNE_MODE_UNINITIALISED:
|
||||||
// autotune has never been run
|
// autotune has never been run
|
||||||
|
@ -40,7 +40,7 @@ void Copter::calc_wp_distance()
|
|||||||
wp_distance = wp_nav->get_wp_distance_to_destination();
|
wp_distance = wp_nav->get_wp_distance_to_destination();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
wp_distance = 0;
|
wp_distance = 0;
|
||||||
break;
|
break;
|
||||||
@ -67,7 +67,7 @@ void Copter::calc_wp_bearing()
|
|||||||
wp_bearing = wp_nav->get_wp_bearing_to_destination();
|
wp_bearing = wp_nav->get_wp_bearing_to_destination();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// no break
|
FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
wp_bearing = 0;
|
wp_bearing = 0;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user