From f1c375335259ffc09a79c183588a49ffbc398b65 Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Thu, 8 Feb 2018 17:25:09 +0100 Subject: [PATCH 1/2] [build] handle fallthru warning in flight plans due to NextStage --- sw/airborne/subsystems/navigation/common_flight_plan.h | 8 ++++---- sw/include/std.h | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sw/airborne/subsystems/navigation/common_flight_plan.h b/sw/airborne/subsystems/navigation/common_flight_plan.h index 31549007764..c540312c0d5 100644 --- a/sw/airborne/subsystems/navigation/common_flight_plan.h +++ b/sw/airborne/subsystems/navigation/common_flight_plan.h @@ -43,16 +43,16 @@ void nav_goto_block(uint8_t block_id); #define InitStage() nav_init_stage(); -#define Block(x) /* Falls through. */ case x: nav_block=x; +#define Block(x) case x: nav_block=x; #define NextBlock() nav_goto_block(nav_block + 1) #define GotoBlock(b) nav_goto_block(b) -#define Stage(s) /* Falls through. */ case s: nav_stage=s; -#define NextStage() { nav_stage++; InitStage(); } +#define Stage(s) case s: nav_stage=s; +#define NextStage() { nav_stage++; InitStage(); } INTENTIONAL_FALLTHRU #define NextStageAndBreak() { nav_stage++; InitStage(); break; } #define NextStageAndBreakFrom(wp) { last_wp = wp; NextStageAndBreak(); } -#define Label(x) /* Falls through. */ label_ ## x: +#define Label(x) label_ ## x: #define Goto(x) { goto label_ ## x; } #define Return(x) { nav_block=last_block; if (x==1) {nav_stage=0;} else {nav_stage=last_stage;} block_time=0;} diff --git a/sw/include/std.h b/sw/include/std.h index 8efc6442a94..97c8b995c3b 100644 --- a/sw/include/std.h +++ b/sw/include/std.h @@ -235,4 +235,10 @@ static inline bool str_equal(const char *a, const char *b) # define WEAK #endif +#if __GNUC__ >= 7 +# define INTENTIONAL_FALLTHRU __attribute__ ((fallthrough)); +#else +# define INTENTIONAL_FALLTHRU +#endif + #endif /* STD_H */ From 64cec590e17d8457a424be3649395f48daffec23 Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Fri, 9 Feb 2018 00:19:12 +0100 Subject: [PATCH 2/2] remove warning in FP for loop --- sw/tools/generators/gen_flight_plan.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/sw/tools/generators/gen_flight_plan.ml b/sw/tools/generators/gen_flight_plan.ml index d5d931f5f3d..7664314fac4 100644 --- a/sw/tools/generators/gen_flight_plan.ml +++ b/sw/tools/generators/gen_flight_plan.ml @@ -384,6 +384,7 @@ let rec print_stage = fun index_of_waypoints x -> stage (); lprintf "%s = %s - 1;\n" v from_; lprintf "%s = %s;\n" to_var to_expr; + lprintf "INTENTIONAL_FALLTHRU\n"; left (); output_label f;