diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index b30c432d30d..c96ad22f201 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -245,14 +245,17 @@ typedef CODE void (*worker_t)(FAR void *arg); struct work_s { - struct sq_entry_s sq; /* Implements a single linked list */ union { - struct wdog_s timer; /* Delay expiry timer */ - clock_t qtime; /* Time work queued */ + struct + { + struct sq_entry_s sq; /* Implements a single linked list */ + clock_t qtime; /* Time work queued */ + } s; + struct wdog_s timer; /* Delay expiry timer */ } u; - worker_t worker; /* Work callback */ - FAR void *arg; /* Callback argument */ + worker_t worker; /* Work callback */ + FAR void *arg; /* Callback argument */ }; /* This is an enumeration of the various events that may be diff --git a/libs/libc/wqueue/work_cancel.c b/libs/libc/wqueue/work_cancel.c index 58c2eb58497..21c967b9a98 100644 --- a/libs/libc/wqueue/work_cancel.c +++ b/libs/libc/wqueue/work_cancel.c @@ -87,7 +87,7 @@ static int work_qcancel(FAR struct usr_wqueue_s *wqueue, */ curr = wqueue->q.head; - while (curr && curr != &work->sq) + while (curr && curr != &work->u.s.sq) { prev = curr; curr = curr->flink; diff --git a/libs/libc/wqueue/work_queue.c b/libs/libc/wqueue/work_queue.c index af665cb9a5b..ba5a822edd5 100644 --- a/libs/libc/wqueue/work_queue.c +++ b/libs/libc/wqueue/work_queue.c @@ -86,9 +86,9 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, /* Initialize the work structure */ - work->worker = worker; /* Work callback. non-NULL means queued */ - work->arg = arg; /* Callback argument */ - work->u.qtime = clock() + delay; /* Delay until work performed */ + work->worker = worker; /* Work callback. non-NULL means queued */ + work->arg = arg; /* Callback argument */ + work->u.s.qtime = clock() + delay; /* Delay until work performed */ /* Do the easy case first -- when the work queue is empty. */ @@ -96,7 +96,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, { /* Add the watchdog to the head == tail of the queue. */ - sq_addfirst(&work->sq, &wqueue->q); + sq_addfirst(&work->u.s.sq, &wqueue->q); _SEM_POST(&wqueue->wake); } @@ -110,7 +110,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, do { - delta = work->u.qtime - ((FAR struct work_s *)curr)->u.qtime; + delta = work->u.s.qtime - ((FAR struct work_s *)curr)->u.s.qtime; if (delta < 0) { break; @@ -127,7 +127,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, { /* Insert the watchdog at the head of the list */ - sq_addfirst(&work->sq, &wqueue->q); + sq_addfirst(&work->u.s.sq, &wqueue->q); _SEM_GETVALUE(&wqueue->wake, &semcount); if (semcount < 1) { @@ -138,7 +138,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue, { /* Insert the watchdog in mid- or end-of-queue */ - sq_addafter(prev, &work->sq, &wqueue->q); + sq_addafter(prev, &work->u.s.sq, &wqueue->q); } } diff --git a/libs/libc/wqueue/work_usrthread.c b/libs/libc/wqueue/work_usrthread.c index 171bd8bde24..64974c58a6b 100644 --- a/libs/libc/wqueue/work_usrthread.c +++ b/libs/libc/wqueue/work_usrthread.c @@ -118,7 +118,7 @@ static void work_process(FAR struct usr_wqueue_s *wqueue) * zero will always execute immediately. */ - elapsed = clock() - work->u.qtime; + elapsed = clock() - work->u.s.qtime; /* Is this delay work ready? */ @@ -173,7 +173,7 @@ static void work_process(FAR struct usr_wqueue_s *wqueue) } else { - next = work->u.qtime - clock(); + next = work->u.s.qtime - clock(); break; } }