Merge pull request #240 from ShFil119/impr/simplify_statements

Simplify some statements
This commit is contained in:
kcat 2018-10-29 10:10:06 -07:00 committed by GitHub
commit 44a4602508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 35 deletions

View File

@ -635,7 +635,7 @@ const char *GetConfigValue(const char *devName, const char *blockName, const cha
int ConfigValueExists(const char *devName, const char *blockName, const char *keyName)
{
const char *val = GetConfigValue(devName, blockName, keyName, "");
return !!val[0];
return val[0] != 0;
}
int ConfigValueStr(const char *devName, const char *blockName, const char *keyName, const char **ret)
@ -692,7 +692,7 @@ int GetConfigValueBool(const char *devName, const char *blockName, const char *k
{
const char *val = GetConfigValue(devName, blockName, keyName, "");
if(!val[0]) return !!def;
if(!val[0]) return def != 0;
return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
strcasecmp(val, "on") == 0 || atoi(val) != 0);
}

View File

@ -842,7 +842,7 @@ static void DirectorySearch(const char *path, const char *ext, vector_al_string
continue;
len = strlen(dirent->d_name);
if(!(len > extlen))
if(len <= extlen)
continue;
if(strcasecmp(dirent->d_name+len-extlen, ext) != 0)
continue;

View File

@ -730,7 +730,7 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsiz
);
bformatdec_reset(device->AmbiDecoder, conf, count, device->Frequency, speakermap);
if(!(conf->ChanMask > 0xf))
if(conf->ChanMask <= 0xf)
{
device->FOAOut.Ambi = device->Dry.Ambi;
device->FOAOut.CoeffCount = device->Dry.CoeffCount;

View File

@ -116,7 +116,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
context = GetContextRef();
if(!context) return;
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Generating %d effect slots", n);
if(n == 0) goto done;
@ -179,7 +179,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
if(!context) return;
LockEffectSlotList(context);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Deleting %d effect slots", n);
if(n == 0) goto done;

View File

@ -77,7 +77,7 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
context = GetContextRef();
if(!context) return;
if(!(n >= 0))
if(n < 0)
alSetError(context, AL_INVALID_VALUE, "Generating %d buffers", n);
else for(cur = 0;cur < n;cur++)
{

View File

@ -81,7 +81,7 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
context = GetContextRef();
if(!context) return;
if(!(n >= 0))
if(n < 0)
alSetError(context, AL_INVALID_VALUE, "Generating %d effects", n);
else for(cur = 0;cur < n;cur++)
{
@ -109,7 +109,7 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
device = context->Device;
LockEffectList(device);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Deleting %d effects", n);
for(i = 0;i < n;i++)
{

View File

@ -61,7 +61,7 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
context = GetContextRef();
if(!context) return;
if(!(n >= 0))
if(n < 0)
alSetError(context, AL_INVALID_VALUE, "Generating %d filters", n);
else for(cur = 0;cur < n;cur++)
{
@ -90,7 +90,7 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
device = context->Device;
LockFilterList(device);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Deleting %d filters", n);
for(i = 0;i < n;i++)
{

View File

@ -988,7 +988,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u",
values[0]);
}
if(!((ALuint)values[1] < (ALuint)device->NumAuxSends))
if((ALuint)values[1] >= (ALuint)device->NumAuxSends)
{
UnlockEffectSlotList(Context);
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid send %u", values[1]);
@ -1683,7 +1683,7 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n, ALuint *sources)
context = GetContextRef();
if(!context) return;
if(!(n >= 0))
if(n < 0)
alSetError(context, AL_INVALID_VALUE, "Generating %d sources", n);
else for(cur = 0;cur < n;cur++)
{
@ -1710,7 +1710,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
if(!context) return;
LockSourceList(context);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Deleting %d sources", n);
/* Check that all Sources are valid */
@ -1761,7 +1761,7 @@ AL_API ALvoid AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value)
LockSourceList(Context);
if((Source=LookupSource(Context, source)) == NULL)
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!(FloatValsByProp(param) == 1))
else if(FloatValsByProp(param) != 1)
alSetError(Context, AL_INVALID_ENUM, "Invalid float property 0x%04x", param);
else
SetSourcefv(Source, Context, param, &value);
@ -1783,7 +1783,7 @@ AL_API ALvoid AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1
LockSourceList(Context);
if((Source=LookupSource(Context, source)) == NULL)
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!(FloatValsByProp(param) == 3))
else if(FloatValsByProp(param) != 3)
alSetError(Context, AL_INVALID_ENUM, "Invalid 3-float property 0x%04x", param);
else
{
@ -1810,7 +1810,7 @@ AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!values)
alSetError(Context, AL_INVALID_VALUE, "NULL pointer");
else if(!(FloatValsByProp(param) > 0))
else if(FloatValsByProp(param) <= 0)
alSetError(Context, AL_INVALID_ENUM, "Invalid float-vector property 0x%04x", param);
else
SetSourcefv(Source, Context, param, values);
@ -1833,7 +1833,7 @@ AL_API ALvoid AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble va
LockSourceList(Context);
if((Source=LookupSource(Context, source)) == NULL)
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!(DoubleValsByProp(param) == 1))
else if(DoubleValsByProp(param) != 1)
alSetError(Context, AL_INVALID_ENUM, "Invalid double property 0x%04x", param);
else
{
@ -1858,7 +1858,7 @@ AL_API ALvoid AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble v
LockSourceList(Context);
if((Source=LookupSource(Context, source)) == NULL)
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!(DoubleValsByProp(param) == 3))
else if(DoubleValsByProp(param) != 3)
alSetError(Context, AL_INVALID_ENUM, "Invalid 3-double property 0x%04x", param);
else
{
@ -1916,7 +1916,7 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value)
LockSourceList(Context);
if((Source=LookupSource(Context, source)) == NULL)
alSetError(Context, AL_INVALID_NAME, "Invalid source ID %u", source);
else if(!(IntValsByProp(param) == 1))
else if(IntValsByProp(param) != 1)
alSetError(Context, AL_INVALID_ENUM, "Invalid integer property 0x%04x", param);
else
SetSourceiv(Source, Context, param, &value);
@ -2568,7 +2568,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
if(!context) return;
LockSourceList(context);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Pausing %d sources", n);
for(i = 0;i < n;i++)
{
@ -2612,7 +2612,7 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
if(!context) return;
LockSourceList(context);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Stopping %d sources", n);
for(i = 0;i < n;i++)
{
@ -2664,7 +2664,7 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
if(!context) return;
LockSourceList(context);
if(!(n >= 0))
if(n < 0)
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Rewinding %d sources", n);
for(i = 0;i < n;i++)
{

View File

@ -47,7 +47,7 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{
@ -130,7 +130,7 @@ ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{
@ -166,7 +166,7 @@ ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{

View File

@ -133,7 +133,7 @@ int main(int argc, char **argv)
break;
else if(strcmp(argv[0], "--channels") == 0 || strcmp(argv[0], "-c") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@ -150,7 +150,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--bits") == 0 || strcmp(argv[0], "-b") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@ -168,7 +168,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--rate") == 0 || strcmp(argv[0], "-r") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@ -185,7 +185,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--time") == 0 || strcmp(argv[0], "-t") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;
@ -202,7 +202,7 @@ int main(int argc, char **argv)
}
else if(strcmp(argv[0], "--outfile") == 0 || strcmp(argv[0], "-o") == 0)
{
if(!(argc > 1))
if(argc < 2)
{
fprintf(stderr, "Missing argument for option: %s\n", argv[0]);
return 1;

View File

@ -419,7 +419,7 @@ ALenum InsertPtrIntMapEntry(PtrIntMap *map, ALvoid *key, ALint value)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{
@ -485,7 +485,7 @@ ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{
@ -521,7 +521,7 @@ ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key)
do {
ALsizei step = count>>1;
ALsizei i = pos+step;
if(!(map->keys[i] < key))
if(map->keys[i] >= key)
count = step;
else
{

View File

@ -916,7 +916,7 @@ void MainWindow::saveConfig(const QString &fname) const
settings.setValue("channels", getValueFromName(speakerModeList, ui->channelConfigCombo->currentText()));
uint rate = ui->sampleRateCombo->currentText().toUInt();
if(!(rate > 0))
if(rate <= 0)
settings.setValue("frequency", QString());
else
settings.setValue("frequency", rate);