diff --git a/ChangeLog b/ChangeLog index a918e5e..502bd42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ Version 1.6.16 ******************************************************************************* +2012-03-14 Fabrice Fontaine + + Use switch insted of if with enums in threadutil + + Replace if statements with switch when using enums in threadutil. + 2012-03-14 Fabrice Fontaine Fix missing break in http_RecvMessage diff --git a/threadutil/src/ThreadPool.c b/threadutil/src/ThreadPool.c index 4544b35..cc03063 100644 --- a/threadutil/src/ThreadPool.c +++ b/threadutil/src/ThreadPool.c @@ -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; } } diff --git a/threadutil/src/TimerThread.c b/threadutil/src/TimerThread.c index 007878b..0c2287a 100644 --- a/threadutil/src/TimerThread.c +++ b/threadutil/src/TimerThread.c @@ -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;