Examples of errors detected by the V796 diagnostic
V796. A 'break' statement is probably missing in a 'switch' statement.
Chromium
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. command_buffer_metrics.cc 125
void RecordContextLost(ContextType type,
CommandBufferContextLostReason reason) {
switch (type) {
....
case MEDIA_CONTEXT:
UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.Media",
reason, CONTEXT_LOST_REASON_MAX_ENUM);
break;
case MUS_CLIENT_CONTEXT:
UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.MusClient",
reason, CONTEXT_LOST_REASON_MAX_ENUM);
break;
case UI_COMPOSITOR_CONTEXT:
UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.UICompositor",
reason, CONTEXT_LOST_REASON_MAX_ENUM);
case CONTEXT_TYPE_UNKNOWN:
UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.Unknown",
reason, CONTEXT_LOST_REASON_MAX_ENUM);
break;
}
}
Chromium
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. system_input_injector_mus.cc 78
void SystemInputInjectorMus::InjectMouseButton(
ui::EventFlags button, bool down)
{
....
int modifier = ui::MODIFIER_NONE;
switch (button) {
case ui::EF_LEFT_MOUSE_BUTTON:
modifier = ui::MODIFIER_LEFT_MOUSE_BUTTON;
break;
case ui::EF_RIGHT_MOUSE_BUTTON:
modifier = ui::MODIFIER_RIGHT_MOUSE_BUTTON;
break;
case ui::EF_MIDDLE_MOUSE_BUTTON:
modifier = ui::MODIFIER_MIDDLE_MOUSE_BUTTON;
default:
LOG(WARNING) << "Invalid flag: " << button
<< " for the button parameter";
return;
}
....
}
Android
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. a2dp_vendor_ldac.cc 912
bool A2dpCodecConfigLdac::setCodecConfig(....) {
....
case BTAV_A2DP_CODEC_SAMPLE_RATE_192000:
if (sampleRate & A2DP_LDAC_SAMPLING_FREQ_192000) {
result_config_cie.sampleRate =
A2DP_LDAC_SAMPLING_FREQ_192000;
codec_capability_.sample_rate =
codec_user_config_.sample_rate;
codec_config_.sample_rate =
codec_user_config_.sample_rate;
}
case BTAV_A2DP_CODEC_SAMPLE_RATE_16000:
case BTAV_A2DP_CODEC_SAMPLE_RATE_24000:
case BTAV_A2DP_CODEC_SAMPLE_RATE_NONE:
codec_capability_.sample_rate =
BTAV_A2DP_CODEC_SAMPLE_RATE_NONE;
codec_config_.sample_rate =
BTAV_A2DP_CODEC_SAMPLE_RATE_NONE;
break;
....
}
Android
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. IAndroidConfiguration.cpp 90
static SLresult IAndroidConfiguration_GetConfiguration(....)
{
....
switch (IObjectToObjectID((thiz)->mThis)) {
case SL_OBJECTID_AUDIORECORDER:
result = android_audioRecorder_getConfig(
(CAudioRecorder *) thiz->mThis, configKey,
pValueSize, pConfigValue);
break;
case SL_OBJECTID_AUDIOPLAYER:
result = android_audioPlayer_getConfig(
(CAudioPlayer *) thiz->mThis, configKey,
pValueSize, pConfigValue);
default:
result = SL_RESULT_FEATURE_UNSUPPORTED;
break;
}
....
}
Android
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. EffectsFactory.cpp 118
Return<void> EffectsFactory::getAllDescriptors(....) {
....
switch (status) {
case -ENOSYS: {
// Effect list has changed.
goto restart;
}
case -ENOENT: {
// No more effects available.
result.resize(i);
}
default: {
result.resize(0);
retval = Result::NOT_INITIALIZED;
}
}
....
}
Android
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. EffectReverb.cpp 1847
int Reverb_getParameter(....)
{
....
case REVERB_PARAM_REFLECTIONS_LEVEL:
*(uint16_t *)pValue = 0;
case REVERB_PARAM_REFLECTIONS_DELAY:
*(uint32_t *)pValue = 0;
case REVERB_PARAM_REVERB_DELAY:
*(uint32_t *)pValue = 0;
break;
....
}
System Shock
V796 It is possible that 'break' statement is missing in switch statement. OLH.C 142
bool olh_candidate(ObjID obj)
{
....
switch (objs[obj].obclass)
{
case CLASS_DOOR:
....
break;
case CLASS_BIGSTUFF:
....
if (....)
{
....
break;
}
case CLASS_SMALLSTUFF:
....
if (....)
{
....
break;
}
// smallstuff falls through to default.
default:
....
break;
}
}
Similar errors can be found in some other places:
- V796 It is possible that 'break' statement is missing in switch statement. GAMEREND.C 777
Godot Engine
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. gdscript_compiler.cpp 135
GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(
const GDScriptParser::DataType &p_datatype) const
{
....
switch (p_datatype.kind) {
....
case GDScriptParser::DataType::NATIVE: {
result.kind = GDScriptDataType::NATIVE;
result.native_type = p_datatype.native_type;
} break;
case GDScriptParser::DataType::SCRIPT: {
result.kind = GDScriptDataType::SCRIPT;
result.script_type = p_datatype.script_type;
result.native_type = result.script_type->get_instance_base_type();
}
case GDScriptParser::DataType::GDSCRIPT: {
result.kind = GDScriptDataType::GDSCRIPT;
result.script_type = p_datatype.script_type;
result.native_type = result.script_type->get_instance_base_type();
} break;
....
}
GPCS4
V796 CWE-484 It is possible that 'break' statement is missing in switch statement. AudioOut.cpp 137
static AudioProperties getAudioProperties(uint32_t param)
{
uint32_t format = param & 0x000000ff;
AudioProperties props = {};
switch (format)
{
....
case SCE_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
{
props.nChannels = 8;
props.bytesPerSample = 2;
props.audioFormat = RTAUDIO_FORMAT_SINT16;
break;
}
case SCE_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
{
props.nChannels = 1;
props.bytesPerSample = 4;
props.audioFormat = RTAUDIO_FORMAT_FLOAT32;
}
case SCE_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
{
props.nChannels = 2;
props.bytesPerSample = 4;
props.audioFormat = RTAUDIO_FORMAT_FLOAT32;
break;
}
}
return props;
}