diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-06-24 12:29:48 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-25 07:32:12 +0000 |
commit | 34374f0683a073ebf0c766c8a043fb720eb9700f (patch) | |
tree | d62bc47bd7ee522b701b2011021d17438c11f5e9 | |
parent | cb34d98b74a449cccc85b4315f3f839c13175426 (diff) |
Avoid (bogus) MSVC warnings (that are now errors)
Two instances of
warning C4723: potential divide by 0
where the numerator is bytesPerSample(); which the code, at least,
consistently assumes is non-zero.
Change-Id: I70630735d631e99b064fab9ec8752ca3d4677bfd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit 76be6a37a211435f2e69d240a1b25b353eba2c11)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/audio/qaudiohelpers.cpp | 4 | ||||
-rw-r--r-- | src/multimedia/audio/qwavedecoder.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/multimedia/audio/qaudiohelpers.cpp b/src/multimedia/audio/qaudiohelpers.cpp index 4d8e983cf..1e7c4ac81 100644 --- a/src/multimedia/audio/qaudiohelpers.cpp +++ b/src/multimedia/audio/qaudiohelpers.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. @@ -74,7 +74,7 @@ template<class T> void adjustUnsignedSamples(qreal factor, const void *src, void void qMultiplySamples(qreal factor, const QAudioFormat &format, const void* src, void* dest, int len) { - int samplesCount = len / (format.bytesPerSample()); + const int samplesCount = len / qMax(1, format.bytesPerSample()); switch (format.sampleFormat()) { case QAudioFormat::Unknown: diff --git a/src/multimedia/audio/qwavedecoder.cpp b/src/multimedia/audio/qwavedecoder.cpp index 8b90a0803..534e66d79 100644 --- a/src/multimedia/audio/qwavedecoder.cpp +++ b/src/multimedia/audio/qwavedecoder.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. @@ -178,7 +178,7 @@ qint64 QWaveDecoder::headerLength() qint64 QWaveDecoder::readData(char *data, qint64 maxlen) { - if (!haveFormat) + if (!haveFormat || format.bytesPerSample() == 0) return 0; qint64 nSamples = maxlen / format.bytesPerSample(); |