Skip to content

Commit

Permalink
Don't use static_cast to convert an enum to an integer
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Mar 8, 2025
1 parent 0152914 commit 1a0e474
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion al/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ NOINLINE void SetProperty(ALsource *const Source, ALCcontext *const Context, con
if constexpr(std::is_integral_v<T>)
{
CheckSize(1);
CheckValue(values[0] >= 0 && values[0] <= static_cast<int>(Resampler::Max));
CheckValue(values[0] >= 0 && values[0] <= al::to_underlying(Resampler::Max));

Source->mResampler = static_cast<Resampler>(values[0]);
return UpdateSourceProps(Source, Context);
Expand Down
2 changes: 1 addition & 1 deletion al/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ FORCE_ALIGN const ALchar* AL_APIENTRY alGetStringiDirectSOFT(ALCcontext *context
switch(pname)
{
case AL_RESAMPLER_NAME_SOFT:
if(index >= 0 && index <= static_cast<ALint>(Resampler::Max))
if(index >= 0 && index <= al::to_underlying(Resampler::Max))
return GetResamplerName(static_cast<Resampler>(index));
context->setError(AL_INVALID_VALUE, "Resampler name index {} out of range", index);
return nullptr;
Expand Down

0 comments on commit 1a0e474

Please sign in to comment.