Silence some static analysis warnings

This commit is contained in:
Chris Robinson 2021-10-03 08:02:57 -07:00
parent 53d9033ec7
commit f92cc479d8
6 changed files with 17 additions and 15 deletions

View File

@ -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);

View File

@ -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{}};

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);