Use switch insted of if with enums in threadutil
Replace if statements with switch when using enums in threadutil. (cherry picked from commit b7f83bb7c6bb1e3466a8c0607e6c367c6d1b2507)
This commit is contained in:
parent
6bd5086a88
commit
f65b68a9bc
@ -318,6 +318,12 @@ Version 1.8.0
|
||||
Version 1.6.16
|
||||
*******************************************************************************
|
||||
|
||||
2012-03-14 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||
|
||||
Use switch insted of if with enums in threadutil
|
||||
|
||||
Replace if statements with switch when using enums in threadutil.
|
||||
|
||||
2012-03-14 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||
|
||||
Fix missing break in http_RecvMessage
|
||||
|
@ -831,13 +831,16 @@ int ThreadPoolAdd(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
|
||||
temp = CreateThreadPoolJob(job, tp->lastJobId, tp);
|
||||
if (!temp)
|
||||
goto exit_function;
|
||||
if (job->priority == HIGH_PRIORITY) {
|
||||
switch (job->priority) {
|
||||
case HIGH_PRIORITY:
|
||||
if (ListAddTail(&tp->highJobQ, temp))
|
||||
rc = 0;
|
||||
} else if (job->priority == MED_PRIORITY) {
|
||||
break;
|
||||
case MED_PRIORITY:
|
||||
if (ListAddTail(&tp->medJobQ, temp))
|
||||
rc = 0;
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
if (ListAddTail(&tp->lowJobQ, temp))
|
||||
rc = 0;
|
||||
}
|
||||
@ -1076,12 +1079,13 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority)
|
||||
{
|
||||
if (!job)
|
||||
return EINVAL;
|
||||
if (priority == (ThreadPriority)LOW_PRIORITY ||
|
||||
priority == (ThreadPriority)MED_PRIORITY ||
|
||||
priority == (ThreadPriority)HIGH_PRIORITY) {
|
||||
switch (priority) {
|
||||
case LOW_PRIORITY:
|
||||
case MED_PRIORITY:
|
||||
case HIGH_PRIORITY:
|
||||
job->priority = priority;
|
||||
return 0;
|
||||
} else {
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -133,9 +133,10 @@ static int CalculateEventTime(
|
||||
|
||||
assert( timeout != NULL );
|
||||
|
||||
if (type == (TimeoutType)ABS_SEC)
|
||||
switch (type) {
|
||||
case ABS_SEC:
|
||||
return 0;
|
||||
else /*if (type == REL_SEC) */{
|
||||
default: /* REL_SEC) */
|
||||
time(&now);
|
||||
( *timeout ) += now;
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user