aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-25 09:34:50 -0700
committerChris Robinson <[email protected]>2023-05-25 09:34:50 -0700
commit4a75de91f6cef6467dadfc307b231235d6c3394b (patch)
treeda826f188626f3d2fcc6b81f072b552f4ed691fc /al
parent68908eebbec50ed8f4343f93fd8cd52427ea7ca8 (diff)
Avoid duplicate NULL checks
Diffstat (limited to 'al')
-rw-r--r--al/buffer.cpp24
-rw-r--r--al/listener.cpp70
2 files changed, 44 insertions, 50 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index 7feac255..edca56ad 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -1060,18 +1060,18 @@ FORCE_ALIGN void AL_APIENTRY alBuffer3iDirect(ALCcontext *context, ALuint buffer
FORCE_ALIGN void AL_APIENTRY alBufferivDirect(ALCcontext *context, ALuint buffer, ALenum param,
const ALint *values) noexcept
{
- if(values)
+ if(!values) UNLIKELY
+ return context->setError(AL_INVALID_VALUE, "NULL pointer");
+
+ switch(param)
{
- switch(param)
- {
- case AL_UNPACK_BLOCK_ALIGNMENT_SOFT:
- case AL_PACK_BLOCK_ALIGNMENT_SOFT:
- case AL_AMBISONIC_LAYOUT_SOFT:
- case AL_AMBISONIC_SCALING_SOFT:
- case AL_UNPACK_AMBISONIC_ORDER_SOFT:
- alBufferiDirect(context, buffer, param, values[0]);
- return;
- }
+ case AL_UNPACK_BLOCK_ALIGNMENT_SOFT:
+ case AL_PACK_BLOCK_ALIGNMENT_SOFT:
+ case AL_AMBISONIC_LAYOUT_SOFT:
+ case AL_AMBISONIC_SCALING_SOFT:
+ case AL_UNPACK_AMBISONIC_ORDER_SOFT:
+ alBufferiDirect(context, buffer, param, values[0]);
+ return;
}
ALCdevice *device{context->mALDevice.get()};
@@ -1080,8 +1080,6 @@ FORCE_ALIGN void AL_APIENTRY alBufferivDirect(ALCcontext *context, ALuint buffer
ALbuffer *albuf = LookupBuffer(device, buffer);
if(!albuf) UNLIKELY
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if(!values) UNLIKELY
- context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
case AL_LOOP_POINTS_SOFT:
diff --git a/al/listener.cpp b/al/listener.cpp
index f7e7d6f0..8d715a10 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -127,25 +127,22 @@ FORCE_ALIGN void AL_APIENTRY alListener3fDirect(ALCcontext *context, ALenum para
FORCE_ALIGN void AL_APIENTRY alListenerfvDirect(ALCcontext *context, ALenum param,
const ALfloat *values) noexcept
{
- if(values)
+ if(!values) UNLIKELY
+ return context->setError(AL_INVALID_VALUE, "NULL pointer");
+
+ switch(param)
{
- switch(param)
- {
- case AL_GAIN:
- case AL_METERS_PER_UNIT:
- alListenerfDirect(context, param, values[0]);
- return;
+ case AL_GAIN:
+ case AL_METERS_PER_UNIT:
+ alListenerfDirect(context, param, values[0]);
+ return;
- case AL_POSITION:
- case AL_VELOCITY:
- alListener3fDirect(context, param, values[0], values[1], values[2]);
- return;
- }
+ case AL_POSITION:
+ case AL_VELOCITY:
+ alListener3fDirect(context, param, values[0], values[1], values[2]);
+ return;
}
- if(!values) UNLIKELY
- return context->setError(AL_INVALID_VALUE, "NULL pointer");
-
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -203,33 +200,32 @@ FORCE_ALIGN void AL_APIENTRY alListener3iDirect(ALCcontext *context, ALenum para
FORCE_ALIGN void AL_APIENTRY alListenerivDirect(ALCcontext *context, ALenum param,
const ALint *values) noexcept
{
- if(values)
+ if(!values) UNLIKELY
+ return context->setError(AL_INVALID_VALUE, "NULL pointer");
+
+ switch(param)
{
- ALfloat fvals[6];
- switch(param)
- {
- case AL_POSITION:
- case AL_VELOCITY:
- alListener3fDirect(context, param, static_cast<ALfloat>(values[0]),
- static_cast<ALfloat>(values[1]), static_cast<ALfloat>(values[2]));
- return;
+ case AL_POSITION:
+ case AL_VELOCITY:
+ alListener3fDirect(context, param, static_cast<ALfloat>(values[0]),
+ static_cast<ALfloat>(values[1]), static_cast<ALfloat>(values[2]));
+ return;
- case AL_ORIENTATION:
- fvals[0] = static_cast<ALfloat>(values[0]);
- fvals[1] = static_cast<ALfloat>(values[1]);
- fvals[2] = static_cast<ALfloat>(values[2]);
- fvals[3] = static_cast<ALfloat>(values[3]);
- fvals[4] = static_cast<ALfloat>(values[4]);
- fvals[5] = static_cast<ALfloat>(values[5]);
- alListenerfvDirect(context, param, fvals);
- return;
- }
+ case AL_ORIENTATION:
+ const ALfloat fvals[6]{
+ static_cast<ALfloat>(values[0]),
+ static_cast<ALfloat>(values[1]),
+ static_cast<ALfloat>(values[2]),
+ static_cast<ALfloat>(values[3]),
+ static_cast<ALfloat>(values[4]),
+ static_cast<ALfloat>(values[5]),
+ };
+ alListenerfvDirect(context, param, fvals);
+ return;
}
std::lock_guard<std::mutex> _{context->mPropLock};
- if(!values) UNLIKELY
- context->setError(AL_INVALID_VALUE, "NULL pointer");
- else switch(param)
+ switch(param)
{
default:
context->setError(AL_INVALID_ENUM, "Invalid listener integer-vector property");