Skip to content

Commit

Permalink
decoder: Avoid unreachable code
Browse files Browse the repository at this point in the history
If all the features are enabled, then the return statement
at the end of the function becomes unreachable code. Avoid it
by adding specific returns when certain paths are unavailable.

PiperOrigin-RevId: 679731916
  • Loading branch information
vigneshvg authored and copybara-github committed Sep 27, 2024
1 parent 486aa60 commit 6f09306
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,30 @@ impl CodecChoice {
match self {
CodecChoice::Auto => {
// Preferred order of codecs in Auto mode: Android MediaCodec, Dav1d, Libgav1.
return CodecChoice::MediaCodec
CodecChoice::MediaCodec
.get_codec()
.or_else(|_| CodecChoice::Dav1d.get_codec())
.or_else(|_| CodecChoice::Libgav1.get_codec());
.or_else(|_| CodecChoice::Libgav1.get_codec())
}
CodecChoice::Dav1d => {
#[cfg(feature = "dav1d")]
{
return Ok(Box::<Dav1d>::default());
}
return Ok(Box::<Dav1d>::default());
#[cfg(not(feature = "dav1d"))]
return Err(AvifError::NoCodecAvailable);
}
CodecChoice::Libgav1 => {
#[cfg(feature = "libgav1")]
{
return Ok(Box::<Libgav1>::default());
}
return Ok(Box::<Libgav1>::default());
#[cfg(not(feature = "libgav1"))]
return Err(AvifError::NoCodecAvailable);
}
CodecChoice::MediaCodec => {
#[cfg(feature = "android_mediacodec")]
{
return Ok(Box::<MediaCodec>::default());
}
return Ok(Box::<MediaCodec>::default());
#[cfg(not(feature = "android_mediacodec"))]
return Err(AvifError::NoCodecAvailable);
}
}
Err(AvifError::NoCodecAvailable)
}
}

Expand Down

0 comments on commit 6f09306

Please sign in to comment.