From f284e71d533e3c2e8a37aad4a2b994b0c63e525d Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Mon, 30 Jan 2023 09:44:12 +0000 Subject: [PATCH] Bug 1812375 - Fix static-analysis warnings TimeUnits.h and FFmpegAudioDecoder.cpp. r=media-playback-reviewers,alwu Differential Revision: https://phabricator.services.mozilla.com/D167914 --- dom/media/TimeUnits.h | 26 +++++++++---------- .../platforms/ffmpeg/FFmpegAudioDecoder.cpp | 6 +++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dom/media/TimeUnits.h b/dom/media/TimeUnits.h index 3af1d3e08fed..3d2560b91932 100644 --- a/dom/media/TimeUnits.h +++ b/dom/media/TimeUnits.h @@ -22,8 +22,8 @@ class TimeIntervals; // CopyChooser specialization for nsTArray template <> struct nsTArray_RelocationStrategy { - typedef nsTArray_RelocateUsingMoveConstructor - Type; + using Type = + nsTArray_RelocateUsingMoveConstructor; }; namespace mozilla { @@ -40,13 +40,13 @@ namespace media { static const int64_t NSECS_PER_S = 1000000000; #ifndef PROCESS_DECODE_LOG -# define PROCESS_DECODE_LOG(sample) \ - MOZ_LOG( \ - sPDMLog, mozilla::LogLevel::Verbose, \ - ("ProcessDecode: mDuration=%" PRIu64 "µs ; mTime=%" PRIu64 \ - "µs ; mTimecode=%" PRIu64 "µs", \ - sample->mDuration.ToMicroseconds(), sample->mTime.ToMicroseconds(), \ - sample->mTimecode.ToMicroseconds())) +# define PROCESS_DECODE_LOG(sample) \ + MOZ_LOG(sPDMLog, mozilla::LogLevel::Verbose, \ + ("ProcessDecode: mDuration=%" PRIu64 "µs ; mTime=%" PRIu64 \ + "µs ; mTimecode=%" PRIu64 "µs", \ + (sample)->mDuration.ToMicroseconds(), \ + (sample)->mTime.ToMicroseconds(), \ + (sample)->mTimecode.ToMicroseconds())) #endif // PROCESS_DECODE_LOG // TimeUnit at present uses a CheckedInt64 as storage. @@ -66,11 +66,11 @@ class TimeUnit final { (aValue <= 0 ? aValue - halfUsec : aValue + halfUsec) * USECS_PER_S; if (val >= double(INT64_MAX)) { return FromMicroseconds(INT64_MAX); - } else if (val <= double(INT64_MIN)) { - return FromMicroseconds(INT64_MIN); - } else { - return FromMicroseconds(int64_t(val)); } + if (val <= double(INT64_MIN)) { + return FromMicroseconds(INT64_MIN); + } + return FromMicroseconds(int64_t(val)); } static constexpr TimeUnit FromMicroseconds(int64_t aValue) { diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp index 00d6078ce8a6..67a723a48bf7 100644 --- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp @@ -438,9 +438,11 @@ AVCodecID FFmpegAudioDecoder::GetCodecId( } #endif return AV_CODEC_ID_MP3; - } else if (aMimeType.EqualsLiteral("audio/flac")) { + } + if (aMimeType.EqualsLiteral("audio/flac")) { return AV_CODEC_ID_FLAC; - } else if (aMimeType.EqualsLiteral("audio/mp4a-latm")) { + } + if (aMimeType.EqualsLiteral("audio/mp4a-latm")) { return AV_CODEC_ID_AAC; }