diff options
author | Chris Robinson <[email protected]> | 2021-10-03 08:02:57 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-10-03 08:02:57 -0700 |
commit | f92cc479d82fbf85591d8918bbf469c4b329c31c (patch) | |
tree | f18d486b88aa274cd172496c133e6a82c1033dbb | |
parent | 53d9033ec70019353dfa255b63cbe9eb21c70888 (diff) |
Silence some static analysis warnings
-rw-r--r-- | al/auxeffectslot.cpp | 1 | ||||
-rw-r--r-- | al/buffer.cpp | 5 | ||||
-rw-r--r-- | al/effect.cpp | 4 | ||||
-rw-r--r-- | al/filter.cpp | 4 | ||||
-rw-r--r-- | al/source.cpp | 6 | ||||
-rw-r--r-- | core/logging.cpp | 12 |
6 files changed, 17 insertions, 15 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index d1ab29ee..ad7ba41e 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -277,6 +277,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context) { return entry.FreeMask != 0; }); auto lidx = static_cast<ALuint>(std::distance(context->mEffectSlotList.begin(), sublist)); auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask)); + ASSUME(slidx < 64); ALeffectslot *slot{::new(sublist->EffectSlots + slidx) ALeffectslot{}}; aluInitEffectPanning(&slot->mSlot, context); diff --git a/al/buffer.cpp b/al/buffer.cpp index b1e4bdf5..088775b8 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -395,11 +395,10 @@ ALbuffer *AllocBuffer(ALCdevice *device) { auto sublist = std::find_if(device->BufferList.begin(), device->BufferList.end(), [](const BufferSubList &entry) noexcept -> bool - { return entry.FreeMask != 0; } - ); - + { return entry.FreeMask != 0; }); auto lidx = static_cast<ALuint>(std::distance(device->BufferList.begin(), sublist)); auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask)); + ASSUME(slidx < 64); ALbuffer *buffer{::new (sublist->Buffers + slidx) ALbuffer{}}; diff --git a/al/effect.cpp b/al/effect.cpp index a15194fd..1d2b9b3c 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -182,10 +182,10 @@ ALeffect *AllocEffect(ALCdevice *device) { auto sublist = std::find_if(device->EffectList.begin(), device->EffectList.end(), [](const EffectSubList &entry) noexcept -> bool - { return entry.FreeMask != 0; } - ); + { return entry.FreeMask != 0; }); auto lidx = static_cast<ALuint>(std::distance(device->EffectList.begin(), sublist)); auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask)); + ASSUME(slidx < 64); ALeffect *effect{::new (sublist->Effects + slidx) ALeffect{}}; InitEffectParams(effect, AL_EFFECT_NULL); diff --git a/al/filter.cpp b/al/filter.cpp index 21a8fee7..1753580e 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -355,10 +355,10 @@ ALfilter *AllocFilter(ALCdevice *device) { auto sublist = std::find_if(device->FilterList.begin(), device->FilterList.end(), [](const FilterSubList &entry) noexcept -> bool - { return entry.FreeMask != 0; } - ); + { return entry.FreeMask != 0; }); auto lidx = static_cast<ALuint>(std::distance(device->FilterList.begin(), sublist)); auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask)); + ASSUME(slidx < 64); ALfilter *filter{::new(sublist->Filters + slidx) ALfilter{}}; InitFilterParams(filter, AL_FILTER_NULL); diff --git a/al/source.cpp b/al/source.cpp index bf499442..e28b938f 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -619,6 +619,7 @@ bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALC } ++vidx; } + assert(newvoice != nullptr); } /* Initialize the new voice and set its starting offset. @@ -737,10 +738,10 @@ ALsource *AllocSource(ALCcontext *context) { auto sublist = std::find_if(context->mSourceList.begin(), context->mSourceList.end(), [](const SourceSubList &entry) noexcept -> bool - { return entry.FreeMask != 0; } - ); + { return entry.FreeMask != 0; }); auto lidx = static_cast<ALuint>(std::distance(context->mSourceList.begin(), sublist)); auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask)); + ASSUME(slidx < 64); ALsource *source{::new(sublist->Sources + slidx) ALsource{}}; @@ -3063,6 +3064,7 @@ START_API_FUNC break; } } + assert(voice != nullptr); voice->mPosition.store(0u, std::memory_order_relaxed); voice->mPositionFrac.store(0, std::memory_order_relaxed); diff --git a/core/logging.cpp b/core/logging.cpp index dd7f53c7..b06fb35a 100644 --- a/core/logging.cpp +++ b/core/logging.cpp @@ -25,12 +25,12 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) std::va_list args, args2; va_start(args, fmt); va_copy(args2, args); - int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; - if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg)) + const int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; + if(unlikely(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))) { dynmsg.resize(static_cast<size_t>(msglen) + 1u); str = dynmsg.data(); - msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2); + std::vsnprintf(str, dynmsg.size(), fmt, args2); } va_end(args2); va_end(args); @@ -59,12 +59,12 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) std::va_list args, args2; va_start(args, fmt); va_copy(args2, args); - int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; - if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg)) + const int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)}; + if(unlikely(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))) { dynmsg.resize(static_cast<size_t>(msglen) + 1u); str = dynmsg.data(); - msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2); + std::vsnprintf(str, dynmsg.size(), fmt, args2); } va_end(args2); va_end(args); |