Coding style change

This commit is contained in:
Nils O. Selåsdal
2012-12-05 18:53:58 +01:00
parent d9c8b2b48a
commit 16e1ac52ec
32 changed files with 236 additions and 234 deletions
+11 -11
View File
@@ -7,14 +7,14 @@ static int timers_cmp(const void *a_, const void *b_)
const struct UCTimer *a = a_;
const struct UCTimer *b = b_;
if(timercmp(&a->timeout, &b->timeout, <)) {
if (timercmp(&a->timeout, &b->timeout, <)) {
return -1;
} else if (timercmp(&a->timeout, &b->timeout, >)) {
return 1;
} else { //check sequence number
if(a->seq < b->seq) {
if (a->seq < b->seq) {
return -1;
} else if(a->seq > b->seq) {
} else if (a->seq > b->seq) {
return 1;
} else { //should never happen
//assert(0);
@@ -48,7 +48,7 @@ void uc_timer_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int u
struct timeval tmp;
assert(timer->callback != NULL);
if(timer->callback == NULL) //must be set.
if (timer->callback == NULL) //must be set.
return;
tmp.tv_sec = sec;
@@ -61,7 +61,7 @@ void uc_timer_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int u
void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
{
if(timer->state == UC_TIMER_INACTIVE) { //already removed , or never added.
if (timer->state == UC_TIMER_INACTIVE) { //already removed , or never added.
//debugging bandaid
timer->ready_entry.tqe_next = (struct UCTimer *)104;
timer->ready_entry.tqe_prev = (struct UCTimer **)105;
@@ -70,7 +70,7 @@ void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
uc_rb_remove(&timers->timers, &timer->rb_node); //remove it, safe for the
//callback to re_add it
if(timer->state == UC_TIMER_PENDING) {
if (timer->state == UC_TIMER_PENDING) {
//timer is pending for callback, remove it from the list
//so code in uc_timers_run does not touch it.
TAILQ_REMOVE(&timers->ready_list, timer, ready_entry);
@@ -81,7 +81,7 @@ void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
int uc_timers_first(const struct UCTimers *timers, struct timeval *first)
{
const RBNode *n = uc_rb_first(&timers->timers);
if(n) {
if (n) {
struct UCTimer *timer = n->data;
*first = timer->timeout;
return 0;
@@ -95,7 +95,7 @@ size_t uc_timer_count(const struct UCTimers *timers)
struct RBNode *n;
size_t count = 0;
for(n = uc_rb_first(&timers->timers); n ; n = uc_rb_next(n)) {
for (n = uc_rb_first(&timers->timers); n ; n = uc_rb_next(n)) {
count++;
}
@@ -119,10 +119,10 @@ int uc_timers_run(struct UCTimers *timers, const struct timeval *now)
*/
assert(TAILQ_EMPTY(&timers->ready_list)); //somethings serious wrong if it isn't already empty
TAILQ_INIT(&timers->ready_list);
for(node = uc_rb_first(&timers->timers); node ; node = uc_rb_next(node)) {
for (node = uc_rb_first(&timers->timers); node ; node = uc_rb_next(node)) {
struct UCTimer *t = node->data;
//Note, timercmp does not work for >=
if(!timercmp(now, &t->timeout, <)) {
if (!timercmp(now, &t->timeout, <)) {
TAILQ_INSERT_TAIL(&timers->ready_list, t, ready_entry);
t->state = UC_TIMER_PENDING; //so uc_timer_remove knows
//it have to remove it from the ready_list
@@ -139,7 +139,7 @@ int uc_timers_run(struct UCTimers *timers, const struct timeval *now)
* we had in the list.
* uc_timer_remove will unlink the timer from this list.
*/
while(!TAILQ_EMPTY(&timers->ready_list)) {
while (!TAILQ_EMPTY(&timers->ready_list)) {
struct UCTimer *t = TAILQ_FIRST(&timers->ready_list);
uc_timer_remove(timers, t);