From 21d81d25ecff91c9171fc10d910abe80ba7ef5fd Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 4 Jan 2025 18:00:41 +0100 Subject: [PATCH] bad: Clearly specify fallthrough in switch/case Part-of: --- .../gst-plugins-bad/ext/fdkaac/gstfdkaacdec.c | 6 ++++++ .../gst-libs/gst/audio/gstnonstreamaudiodecoder.c | 3 +-- .../gst-plugins-bad/gst-libs/gst/isoff/gstisoff.c | 1 + subprojects/gst-plugins-bad/gst/aiff/aiffparse.c | 4 ++-- .../gst/dvbsuboverlay/gstdvbsuboverlay.c | 1 + .../gst-plugins-bad/gst/mpegpsmux/psmuxstream.c | 1 + .../gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c | 1 + .../gst-plugins-bad/gst/mpegtsdemux/pesparse.c | 2 +- subprojects/gst-plugins-bad/gst/rtmp2/rtmp/amf.c | 6 +++--- .../gst/rtmp2/rtmp/rtmpchunkstream.c | 14 ++++++++------ .../gst/videoparsers/gsth266parse.c | 8 ++++---- .../gst/videoparsers/gstmpeg4videoparse.c | 1 + .../gst/videoparsers/gstmpegvideoparse.c | 4 ++++ .../sys/ipcpipeline/gstipcpipelinesrc.c | 3 ++- subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c | 1 + .../gst-plugins-bad/sys/msdk/gstmsdkh265enc.c | 1 + subprojects/gst-plugins-bad/sys/va/gstvabasedec.c | 2 +- subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c | 2 +- .../examples/audiomixmatrix/test-audiomixmatrix.c | 1 + .../tests/examples/waylandsink/wayland-threads.c | 1 + 20 files changed, 42 insertions(+), 21 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacdec.c b/subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacdec.c index e43a2f0416..2643b994a9 100644 --- a/subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacdec.c +++ b/subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacdec.c @@ -305,6 +305,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, switch (n_front) { case 7: SHIFT_CHAN (front, FRONT_CENTER); + /* FALLTHROUGH */ case 6: SHIFT_CHAN (front, FRONT_LEFT_OF_CENTER); SHIFT_CHAN (front, FRONT_RIGHT_OF_CENTER); @@ -316,6 +317,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, case 5: SHIFT_CHAN (front, FRONT_CENTER); + /* FALLTHROUGH */ case 4: SHIFT_CHAN (front, FRONT_LEFT_OF_CENTER); SHIFT_CHAN (front, FRONT_RIGHT_OF_CENTER); @@ -325,6 +327,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, case 3: SHIFT_CHAN (front, FRONT_CENTER); + /* FALLTHROUGH */ case 2: SHIFT_CHAN (front, FRONT_LEFT); SHIFT_CHAN (front, FRONT_RIGHT); @@ -394,6 +397,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, switch (n_top_front) { case 3: SHIFT_CHAN (top_front, TOP_FRONT_CENTER); + /* FALLTHROUGH */ case 2: SHIFT_CHAN (top_front, TOP_FRONT_LEFT); SHIFT_CHAN (top_front, TOP_FRONT_RIGHT); @@ -407,6 +411,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, switch (n_top_center) { case 3: SHIFT_CHAN (top_center, TOP_CENTER); + /* FALLTHROUGH */ case 2: SHIFT_CHAN (top_center, TOP_SIDE_LEFT); SHIFT_CHAN (top_center, TOP_SIDE_RIGHT); @@ -437,6 +442,7 @@ gst_fdkaacdec_map_channels (GstFdkAacDec * self, const CStreamInfo * in, switch (n_bottom_front) { case 3: SHIFT_CHAN (bottom_front, BOTTOM_FRONT_CENTER); + /* FALLTHROUGH */ case 2: SHIFT_CHAN (bottom_front, BOTTOM_FRONT_LEFT); SHIFT_CHAN (bottom_front, BOTTOM_FRONT_RIGHT); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/audio/gstnonstreamaudiodecoder.c b/subprojects/gst-plugins-bad/gst-libs/gst/audio/gstnonstreamaudiodecoder.c index 89b05e8333..e8da770d61 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/audio/gstnonstreamaudiodecoder.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/audio/gstnonstreamaudiodecoder.c @@ -2117,8 +2117,7 @@ gst_nonstream_audio_decoder_output_task (GstNonstreamAudioDecoder * dec) GST_DEBUG_OBJECT (dec, "trying to renegotiate"); break; } - /* fallthrough to default */ - + /* FALLTHROUGH */ default: GST_ELEMENT_ERROR (dec, STREAM, FAILED, ("Internal data flow error."), ("streaming task paused, reason %s (%d)", gst_flow_get_name (flow), diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/isoff/gstisoff.c b/subprojects/gst-plugins-bad/gst-libs/gst/isoff/gstisoff.c index 56e2a064d9..84ad8c8315 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/isoff/gstisoff.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/isoff/gstisoff.c @@ -845,6 +845,7 @@ gst_isoff_sidx_parser_parse (GstSidxParser * parser, parser->status = GST_ISOFF_SIDX_PARSER_HEADER; + G_GNUC_FALLTHROUGH; case GST_ISOFF_SIDX_PARSER_HEADER: remaining = gst_byte_reader_get_remaining (reader); if (remaining < 12 + (parser->sidx.version == 0 ? 8 : 16)) { diff --git a/subprojects/gst-plugins-bad/gst/aiff/aiffparse.c b/subprojects/gst-plugins-bad/gst/aiff/aiffparse.c index cc96d7570d..9eb700a48f 100644 --- a/subprojects/gst-plugins-bad/gst/aiff/aiffparse.c +++ b/subprojects/gst-plugins-bad/gst/aiff/aiffparse.c @@ -1557,7 +1557,7 @@ gst_aiff_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) if (aiff->state != AIFF_PARSE_HEADER) break; - /* otherwise fall-through */ + G_GNUC_FALLTHROUGH; case AIFF_PARSE_HEADER: GST_INFO_OBJECT (aiff, "AIFF_PARSE_HEADER"); if ((ret = gst_aiff_parse_stream_headers (aiff)) != GST_FLOW_OK) @@ -1569,7 +1569,7 @@ gst_aiff_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) aiff->state = AIFF_PARSE_DATA; GST_INFO_OBJECT (aiff, "AIFF_PARSE_DATA"); - /* fall-through */ + /* FALLTHROUGH */ case AIFF_PARSE_DATA: if ((ret = gst_aiff_parse_stream_data (aiff)) != GST_FLOW_OK) goto done; diff --git a/subprojects/gst-plugins-bad/gst/dvbsuboverlay/gstdvbsuboverlay.c b/subprojects/gst-plugins-bad/gst/dvbsuboverlay/gstdvbsuboverlay.c index 72936614f9..37174a1dfc 100644 --- a/subprojects/gst-plugins-bad/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/subprojects/gst-plugins-bad/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -1226,6 +1226,7 @@ gst_dvbsub_overlay_event_video (GstPad * pad, GstObject * parent, } case GST_EVENT_FLUSH_STOP: gst_segment_init (&render->video_segment, GST_FORMAT_TIME); + /* FALLTHROUGH */ default: ret = gst_pad_push_event (render->srcpad, event); break; diff --git a/subprojects/gst-plugins-bad/gst/mpegpsmux/psmuxstream.c b/subprojects/gst-plugins-bad/gst/mpegpsmux/psmuxstream.c index 92564c22c2..a340e42efb 100644 --- a/subprojects/gst-plugins-bad/gst/mpegpsmux/psmuxstream.c +++ b/subprojects/gst-plugins-bad/gst/mpegpsmux/psmuxstream.c @@ -81,6 +81,7 @@ psmux_stream_new (PsMux * mux, PsMuxStreamType stream_type) case PSMUX_ST_AUDIO_MPEG1: case PSMUX_ST_AUDIO_MPEG2: stream->max_buffer_size = 2484; /* ISO/IEC 13818 2.5.2.4 */ + /* FALLTHROUGH */ case PSMUX_ST_AUDIO_AAC: if (info->id_mpga > PSMUX_STREAM_ID_MPGA_MAX) break; diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c index a8416589c7..e69fb37152 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c @@ -785,6 +785,7 @@ _stream_is_private_section (const GstMpegtsPMT * pmt, if (registration_id != DRF_ID_CUEI && registration_id != DRF_ID_ETV1) return FALSE; } + /* FALLTHROUGH */ case GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS: case GST_MPEGTS_STREAM_TYPE_MHEG: case GST_MPEGTS_STREAM_TYPE_DSM_CC: diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/pesparse.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/pesparse.c index e0f11f2a08..4e001d23f0 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/pesparse.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/pesparse.c @@ -209,7 +209,7 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res) case PES_TRICK_MODE_FAST_REVERSE: res->intra_slice_refresh = (val8 >> 2) & 0x1; res->frequency_truncation = val8 & 0x3; - /* passthrough */ + G_GNUC_FALLTHROUGH; case PES_TRICK_MODE_FREEZE_FRAME: res->field_id = (val8 >> 3) & 0x3; break; diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/amf.c b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/amf.c index fe267f1417..c7dcba56a9 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/amf.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/amf.c @@ -540,14 +540,14 @@ dump_node (GString * string, const GstAmfNode * node, gint indent, case GST_AMF_TYPE_LONG_STRING: g_string_append_c (string, 'L'); - /* no break */ + G_GNUC_FALLTHROUGH; case GST_AMF_TYPE_STRING: dump_bytes (string, node->value.v_bytes); break; case GST_AMF_TYPE_ECMA_ARRAY: object_delim = "[]"; - /* no break */ + G_GNUC_FALLTHROUGH; case GST_AMF_TYPE_OBJECT:{ guint i, len = gst_amf_node_get_num_fields (node); g_string_append_c (string, object_delim[0]); @@ -566,8 +566,8 @@ dump_node (GString * string, const GstAmfNode * node, gint indent, dump_indent (string, indent, recursion_depth); } g_string_append_c (string, object_delim[1]); - break; } + break; case GST_AMF_TYPE_STRICT_ARRAY:{ guint i, len = gst_amf_node_get_num_elements (node); diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpchunkstream.c b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpchunkstream.c index 617f884464..1ec3902ef8 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpchunkstream.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpchunkstream.c @@ -309,15 +309,15 @@ serialize_next (GstRtmpChunkStream * cstream, guint32 chunk_size, case CHUNK_TYPE_0: /* SRSLY: "Message stream ID is stored in little-endian format." */ GST_WRITE_UINT32_LE (map.data + offset + 7, meta->mstream); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_1: GST_WRITE_UINT24_BE (map.data + offset + 3, meta->size); GST_WRITE_UINT8 (map.data + offset + 6, meta->type); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_2: GST_WRITE_UINT24_BE (map.data + offset, ext_ts ? 0xffffff : meta->ts_delta); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_3: offset += chunk_header_sizes[type]; @@ -325,6 +325,7 @@ serialize_next (GstRtmpChunkStream * cstream, guint32 chunk_size, GST_WRITE_UINT32_BE (map.data + offset, meta->ts_delta); offset += 4; } + break; } g_assert (offset == header_size); @@ -462,14 +463,14 @@ gst_rtmp_chunk_stream_parse_header (GstRtmpChunkStream * cstream, has_abs_timestamp = TRUE; /* SRSLY: "Message stream ID is stored in little-endian format." */ meta->mstream = GST_READ_UINT32_LE (message_header + 7); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_1: meta->type = GST_READ_UINT8 (message_header + 6); meta->size = GST_READ_UINT24_BE (message_header + 3); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_2: meta->ts_delta = GST_READ_UINT24_BE (message_header); - /* no break */ + /* FALLTHROUGH */ case CHUNK_TYPE_3: if (needs_ext_ts (meta)) { guint32 timestamp; @@ -491,6 +492,7 @@ gst_rtmp_chunk_stream_parse_header (GstRtmpChunkStream * cstream, header_size += 4; } } + break; } GST_MEMDUMP ("<<< chunk header", data, header_size); diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gsth266parse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gsth266parse.c index d63767e18b..02abbd450e 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gsth266parse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gsth266parse.c @@ -1553,8 +1553,8 @@ get_compatible_profiles (GstH266Profile profile) g_array_append_val (profiles, p); p = GST_H266_PROFILE_MAIN_16_444_STILL_PICTURE; g_array_append_val (profiles, p); - /* Fall down. */ } + /* FALLTHROUGH */ case GST_H266_PROFILE_MAIN_12_444: { /* A.3.5 */ @@ -1594,8 +1594,8 @@ get_compatible_profiles (GstH266Profile profile) /* A.3.5 */ p = GST_H266_PROFILE_MAIN_16_444_STILL_PICTURE; g_array_append_val (profiles, p); - /* Fall down. */ } + /* FALLTHROUGH */ case GST_H266_PROFILE_MAIN_12_444_INTRA: { /* A.3.5 */ @@ -1618,8 +1618,8 @@ get_compatible_profiles (GstH266Profile profile) /* A.3.5 */ p = GST_H266_PROFILE_MAIN_12_444_STILL_PICTURE; g_array_append_val (profiles, p); - /* Fall down. */ } + /* FALLTHROUGH */ case GST_H266_PROFILE_MAIN_12_444_STILL_PICTURE: { /* A.3.5 */ @@ -1627,8 +1627,8 @@ get_compatible_profiles (GstH266Profile profile) g_array_append_val (profiles, p); p = GST_H266_PROFILE_MAIN_12_STILL_PICTURE; g_array_append_val (profiles, p); - /* Fall down. */ } + /* FALLTHROUGH */ case GST_H266_PROFILE_MAIN_12_STILL_PICTURE: { /* A.3.5 */ diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gstmpeg4videoparse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gstmpeg4videoparse.c index 1214a26559..e9a6890d22 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gstmpeg4videoparse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gstmpeg4videoparse.c @@ -494,6 +494,7 @@ next: ret = gst_mpeg4vparse_process_sc (mp4vparse, &packet, size); if (ret) break; + /* FALLTHROUGH */ case (GST_MPEG4_PARSER_NO_PACKET): case (GST_MPEG4_PARSER_ERROR): /* if draining, take all */ diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gstmpegvideoparse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gstmpegvideoparse.c index 779b3af895..a6107773dc 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gstmpegvideoparse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gstmpegvideoparse.c @@ -869,6 +869,7 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) switch (level_c) { case 2: level = levels[0]; + /* FALLTHROUGH */ case 5: if (!level) level = levels[2]; @@ -876,12 +877,15 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse) break; case 10: level = levels[0]; + /* FALLTHROUGH */ case 11: if (!level) level = levels[1]; + /* FALLTHROUGH */ case 13: if (!level) level = levels[2]; + /* FALLTHROUGH */ case 14: if (!level) level = levels[3]; diff --git a/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinesrc.c b/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinesrc.c index 9d46d63b0e..afc70f6542 100644 --- a/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinesrc.c +++ b/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinesrc.c @@ -565,8 +565,9 @@ gst_ipc_pipeline_src_forward_message (GstIpcPipelineSrc * src, GstMessage * msg) GST_DEBUG_OBJECT (src, "Detected lost state, notifying master"); gst_ipc_pipeline_comm_write_state_lost_to_fd (&src->comm); } - /* fall through & skip */ + /* and skip */ } + /* FALLTHROUGH */ case GST_MESSAGE_ASYNC_START: case GST_MESSAGE_CLOCK_PROVIDE: case GST_MESSAGE_CLOCK_LOST: diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c index c32f6f6e57..d201d5f74b 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c @@ -189,6 +189,7 @@ ensure_bitrate_control (GstMsdkEnc * thiz) case MFX_RATECONTROL_LA_ICQ: option2->LookAheadDepth = thiz->lookahead_depth; + /* FALLTHROUGH */ case MFX_RATECONTROL_ICQ: mfx->ICQQuality = CLAMP (thiz->qpi, 1, 51); break; diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkh265enc.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkh265enc.c index b182643033..652f021ae4 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkh265enc.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkh265enc.c @@ -945,6 +945,7 @@ gst_msdkh265enc_is_format_supported (GstMsdkEnc * encoder, h265enc->tune_mode == MFX_CODINGOPTION_OFF) return TRUE; #endif + /* FALLTHROUGH */ default: return FALSE; } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index ca9dba22af..9962c027ed 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -202,8 +202,8 @@ gst_va_base_dec_src_query (GstVideoDecoder * decoder, GstQuery * query) ret = TRUE; break; } - /* else jump to default */ } + /* FALLTHROUGH */ default: ret = GST_VIDEO_DECODER_CLASS (GST_VA_BASE_DEC_GET_PARENT_CLASS (decoder))->src_query (decoder, query); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c index 258c4f22d4..c522faf46b 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c @@ -881,8 +881,8 @@ gst_va_base_enc_src_query (GstVideoEncoder * venc, GstQuery * query) ret = TRUE; break; } - /* else jump to default */ } + /* FALLTHROUGH */ default: ret = GST_VIDEO_ENCODER_CLASS (parent_class)->src_query (venc, query); break; diff --git a/subprojects/gst-plugins-bad/tests/examples/audiomixmatrix/test-audiomixmatrix.c b/subprojects/gst-plugins-bad/tests/examples/audiomixmatrix/test-audiomixmatrix.c index d75a60b77a..15cbcc11a7 100644 --- a/subprojects/gst-plugins-bad/tests/examples/audiomixmatrix/test-audiomixmatrix.c +++ b/subprojects/gst-plugins-bad/tests/examples/audiomixmatrix/test-audiomixmatrix.c @@ -37,6 +37,7 @@ message_cb (GstBus * bus, GstMessage * message, gpointer user_data) g_error_free (err); g_free (debug); } + /* FALLTHROUGH */ case GST_MESSAGE_EOS: g_main_loop_quit (user_data); break; diff --git a/subprojects/gst-plugins-bad/tests/examples/waylandsink/wayland-threads.c b/subprojects/gst-plugins-bad/tests/examples/waylandsink/wayland-threads.c index a2fde962b0..6f5ea3c1ef 100644 --- a/subprojects/gst-plugins-bad/tests/examples/waylandsink/wayland-threads.c +++ b/subprojects/gst-plugins-bad/tests/examples/waylandsink/wayland-threads.c @@ -56,6 +56,7 @@ message_cb (GstBus * bus, GstMessage * message, gpointer user_data) g_error_free (err); g_free (debug); } + /* FALLTHROUGH */ case GST_MESSAGE_EOS: if (retry <= 0) g_main_loop_quit (app->loop);