diff --git a/pipewire-alsa/alsa-plugins/pcm_pipewire.c b/pipewire-alsa/alsa-plugins/pcm_pipewire.c index 9801ccac9..8bd2a6630 100644 --- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c +++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c @@ -497,7 +497,7 @@ static int set_default_channels(struct spa_audio_info_raw *info) case 7: info->position[5] = SPA_AUDIO_CHANNEL_SL; info->position[6] = SPA_AUDIO_CHANNEL_SR; - /* Fall through */ + SPA_FALLTHROUGH case 5: info->position[3] = SPA_AUDIO_CHANNEL_RL; info->position[4] = SPA_AUDIO_CHANNEL_RR; @@ -508,17 +508,17 @@ static int set_default_channels(struct spa_audio_info_raw *info) case 8: info->position[6] = SPA_AUDIO_CHANNEL_SL; info->position[7] = SPA_AUDIO_CHANNEL_SR; - /* Fall through */ + SPA_FALLTHROUGH case 6: info->position[4] = SPA_AUDIO_CHANNEL_RL; info->position[5] = SPA_AUDIO_CHANNEL_RR; - /* Fall through */ + SPA_FALLTHROUGH case 4: info->position[3] = SPA_AUDIO_CHANNEL_LFE; - /* Fall through */ + SPA_FALLTHROUGH case 3: info->position[2] = SPA_AUDIO_CHANNEL_FC; - /* Fall through */ + SPA_FALLTHROUGH case 2: info->position[0] = SPA_AUDIO_CHANNEL_FL; info->position[1] = SPA_AUDIO_CHANNEL_FR; diff --git a/pipewire-pulseaudio/src/channelmap.c b/pipewire-pulseaudio/src/channelmap.c index 95be204f4..c86bb09f7 100644 --- a/pipewire-pulseaudio/src/channelmap.c +++ b/pipewire-pulseaudio/src/channelmap.c @@ -228,7 +228,7 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER; m->map[3] = PA_CHANNEL_POSITION_REAR_LEFT; m->map[4] = PA_CHANNEL_POSITION_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 2: m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; @@ -262,20 +262,20 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p case 8: m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT; m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 6: m->map[5] = PA_CHANNEL_POSITION_LFE; - /* Fall through */ + SPA_FALLTHROUGH case 5: m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 4: m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT; m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 2: m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; @@ -308,44 +308,44 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p m->map[15] = PA_CHANNEL_POSITION_TOP_REAR_LEFT; m->map[16] = PA_CHANNEL_POSITION_TOP_REAR_CENTER; m->map[17] = PA_CHANNEL_POSITION_TOP_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 15: m->map[12] = PA_CHANNEL_POSITION_TOP_FRONT_LEFT; m->map[13] = PA_CHANNEL_POSITION_TOP_FRONT_CENTER; m->map[14] = PA_CHANNEL_POSITION_TOP_FRONT_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 12: m->map[11] = PA_CHANNEL_POSITION_TOP_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 11: m->map[9] = PA_CHANNEL_POSITION_SIDE_LEFT; m->map[10] = PA_CHANNEL_POSITION_SIDE_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 9: m->map[8] = PA_CHANNEL_POSITION_REAR_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 8: m->map[6] = PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER; m->map[7] = PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 6: m->map[4] = PA_CHANNEL_POSITION_REAR_LEFT; m->map[5] = PA_CHANNEL_POSITION_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 4: m->map[3] = PA_CHANNEL_POSITION_LFE; - /* Fall through */ + SPA_FALLTHROUGH case 3: m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 2: m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; @@ -366,20 +366,20 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p case 8: m->map[6] = PA_CHANNEL_POSITION_REAR_LEFT; m->map[7] = PA_CHANNEL_POSITION_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 6: m->map[4] = PA_CHANNEL_POSITION_SIDE_LEFT; m->map[5] = PA_CHANNEL_POSITION_SIDE_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 4: m->map[3] = PA_CHANNEL_POSITION_LFE; - /* Fall through */ + SPA_FALLTHROUGH case 3: m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 2: m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c index eac66fd07..6941c7b34 100644 --- a/pipewire-pulseaudio/src/context.c +++ b/pipewire-pulseaudio/src/context.c @@ -994,7 +994,7 @@ static void node_event_info(void *object, const struct pw_node_info *info) switch (id) { case SPA_PARAM_EnumFormat: clear_node_formats(g); - /* fallthrough */ + SPA_FALLTHROUGH case SPA_PARAM_Props: case SPA_PARAM_Format: do_enum = true; diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h index 875de3e6e..9ba3288f4 100644 --- a/spa/include/spa/pod/builder.h +++ b/spa/include/spa/pod/builder.h @@ -587,6 +587,7 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args) if (type == 0) goto exit; spa_pod_builder_control(builder, offset, type); + SPA_FALLTHROUGH } default: break; diff --git a/spa/include/spa/pod/parser.h b/spa/include/spa/pod/parser.h index 31f4c8849..52f8ef1f0 100644 --- a/spa/include/spa/pod/parser.h +++ b/spa/include/spa/pod/parser.h @@ -420,11 +420,11 @@ do { \ case 'a': \ va_arg(args, void*); \ va_arg(args, void*); \ - /* fallthrough */ \ + SPA_FALLTHROUGH \ case 'p': \ case 'y': \ va_arg(args, void*); \ - /* fallthrough */ \ + SPA_FALLTHROUGH \ case 'b': \ case 'I': \ case 'i': \ diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h index 95b16b902..c3d927535 100644 --- a/spa/include/spa/utils/defs.h +++ b/spa/include/spa/utils/defs.h @@ -36,6 +36,30 @@ extern "C" { #include #include +/** + * SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch + * cases that fall through without a break or return statement. SPA_FALLTHROUGH + * is only needed on cases that have code: + * + * switch (foo) { + * case 1: // These cases have no code. No fallthrough annotations are needed. + * case 2: + * case 3: + * foo = 4; // This case has code, so a fallthrough annotation is needed: + * SPA_FALLTHROUGH; + * default: + * return foo; + * } + */ +#if defined(__clang__) && __cplusplus >= 201103L + /* clang's fallthrough annotations are only available starting in C++11. */ +# define SPA_FALLTHROUGH [[clang::fallthrough]]; +#elif defined(__GNUC__) && __GNUC__ >= 7 + #define SPA_FALLTHROUGH __attribute__ ((fallthrough)); +#else +# define SPA_FALLTHROUGH /* FALLTHROUGH */ +#endif + #define SPA_FLAG_MASK(field,mask,flag) (((field) & (mask)) == (flag)) #define SPA_FLAG_IS_SET(field,flag) SPA_FLAG_MASK(field,flag,flag) #define SPA_FLAG_SET(field,flag) ((field) |= (flag)) diff --git a/spa/plugins/alsa/acp/alsa-util.c b/spa/plugins/alsa/acp/alsa-util.c index 82a7c1b67..48f553e03 100644 --- a/spa/plugins/alsa/acp/alsa-util.c +++ b/spa/plugins/alsa/acp/alsa-util.c @@ -1114,7 +1114,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) { } pa_log_warn("Could not recover alsa device from SUSPENDED state, trying to restart PCM"); } - /* Fall through */ + SPA_FALLTHROUGH default: diff --git a/spa/plugins/alsa/acp/channelmap.h b/spa/plugins/alsa/acp/channelmap.h index bb713b5d3..9a2ec74a2 100644 --- a/spa/plugins/alsa/acp/channelmap.h +++ b/spa/plugins/alsa/acp/channelmap.h @@ -25,6 +25,8 @@ extern "C" { #endif +#include + #define PA_CHANNELS_MAX 64 #define PA_CHANNEL_MAP_SNPRINT_MAX 336 @@ -161,17 +163,17 @@ static inline pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsign case 8: m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT; m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 6: m->map[5] = PA_CHANNEL_POSITION_LFE; - /* Fall through */ + SPA_FALLTHROUGH case 5: m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER; - /* Fall through */ + SPA_FALLTHROUGH case 4: m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT; m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT; - /* Fall through */ + SPA_FALLTHROUGH case 2: m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; diff --git a/spa/plugins/alsa/acp/meson.build b/spa/plugins/alsa/acp/meson.build index 360a5b04c..27b41902c 100644 --- a/spa/plugins/alsa/acp/meson.build +++ b/spa/plugins/alsa/acp/meson.build @@ -18,6 +18,6 @@ acp_lib = static_library( 'acp', acp_sources, c_args : acp_c_args, - include_directories : [configinc], + include_directories : [configinc, spa_inc ], dependencies : [ alsa_dep, mathlib, ] ) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 569e0beb3..0967f436a 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -516,7 +516,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman break; case SPA_NODE_COMMAND_Suspend: configure_format(this, 0, NULL); - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 68a4a9516..618f96afa 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -808,7 +808,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Suspend: clean_convert(this); - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index 10dc31ec9..674981d23 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -172,17 +172,17 @@ static uint64_t default_mask(uint32_t channels) case 8: mask |= _MASK(RL); mask |= _MASK(RR); - /* fallthrough */ + SPA_FALLTHROUGH case 5: case 6: mask |= _MASK(SL); mask |= _MASK(SR); if ((channels & 1) == 0) mask |= _MASK(LFE); - /* fallthrough */ + SPA_FALLTHROUGH case 3: mask |= _MASK(FC); - /* fallthrough */ + SPA_FALLTHROUGH case 2: mask |= _MASK(FL); mask |= _MASK(FR); @@ -466,7 +466,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman this->started = true; break; case SPA_NODE_COMMAND_Suspend: - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 1e0afbe45..9c7fb42aa 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -248,7 +248,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman this->started = true; break; case SPA_NODE_COMMAND_Suspend: - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 1431bdac3..6c3007b81 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -348,7 +348,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman this->started = true; break; case SPA_NODE_COMMAND_Suspend: - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 0d2b45ca2..5751a4838 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -262,7 +262,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman update_rate_match(this); break; case SPA_NODE_COMMAND_Suspend: - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: resample_reset(&this->resample); this->started = false; diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index bc82fac7a..797b90200 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -330,7 +330,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman this->started = true; break; case SPA_NODE_COMMAND_Suspend: - /* fallthrough */ + SPA_FALLTHROUGH case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 24fc70f86..b179f436d 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -229,12 +229,12 @@ static int do_negotiate(struct pw_impl_link *this) case -EIO: current = NULL; res = 0; - /* fallthrough */ + SPA_FALLTHROUGH case 1: break; case 0: res = -EBADF; - /* fallthrough */ + SPA_FALLTHROUGH default: error = spa_aprintf("error get output format: %s", spa_strerror(res)); goto error; @@ -263,12 +263,12 @@ static int do_negotiate(struct pw_impl_link *this) case -EIO: current = NULL; res = 0; - /* fallthrough */ + SPA_FALLTHROUGH case 1: break; case 0: res = -EBADF; - /* fallthrough */ + SPA_FALLTHROUGH default: error = spa_aprintf("error get input format: %s", spa_strerror(res)); goto error;