Changeset b7fd2a0 in mainline for kernel/generic/src/synch


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

Location:
kernel/generic/src/synch
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/condvar.c

    r36f0738 rb7fd2a0  
    8585 * @return              See comment for waitq_sleep_timeout().
    8686 */
    87 int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)
     87errno_t _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)
    8888{
    89         int rc;
     89        errno_t rc;
    9090        ipl_t ipl;
    9191        bool blocked;
     
    124124 * @return See comment for waitq_sleep_timeout().
    125125 */
    126 int _condvar_wait_timeout_spinlock_impl(condvar_t *cv, spinlock_t *lock,
     126errno_t _condvar_wait_timeout_spinlock_impl(condvar_t *cv, spinlock_t *lock,
    127127        uint32_t usec, int flags)
    128128{
    129         int rc;
     129        errno_t rc;
    130130        ipl_t ipl;
    131131        bool blocked;
     
    161161 * @return See comment for waitq_sleep_timeout().
    162162 */
    163 int _condvar_wait_timeout_irq_spinlock(condvar_t *cv, irq_spinlock_t *irq_lock,
     163errno_t _condvar_wait_timeout_irq_spinlock(condvar_t *cv, irq_spinlock_t *irq_lock,
    164164        uint32_t usec, int flags)
    165165{
    166         int rc;
     166        errno_t rc;
    167167        /* Save spinlock's state so we can restore it correctly later on. */
    168168        ipl_t ipl = irq_lock->ipl;
  • kernel/generic/src/synch/futex.c

    r36f0738 rb7fd2a0  
    398398 *                      waitq_sleep_timeout().
    399399 */
    400 sysarg_t sys_futex_sleep(uintptr_t uaddr)
     400sys_errno_t sys_futex_sleep(uintptr_t uaddr)
    401401{
    402402        futex_t *futex = get_futex(uaddr);
    403403       
    404404        if (!futex)
    405                 return (sysarg_t) ENOENT;
     405                return (sys_errno_t) ENOENT;
    406406
    407407#ifdef CONFIG_UDEBUG
     
    409409#endif
    410410
    411         int rc = waitq_sleep_timeout(
     411        errno_t rc = waitq_sleep_timeout(
    412412            &futex->wq, 0, SYNCH_FLAGS_INTERRUPTIBLE, NULL);
    413413
     
    416416#endif
    417417
    418         return (sysarg_t) rc;
     418        return (sys_errno_t) rc;
    419419}
    420420
     
    425425 * @return              ENOENT if there is no physical mapping for uaddr.
    426426 */
    427 sysarg_t sys_futex_wakeup(uintptr_t uaddr)
     427sys_errno_t sys_futex_wakeup(uintptr_t uaddr)
    428428{
    429429        futex_t *futex = get_futex(uaddr);
     
    433433                return EOK;
    434434        } else {
    435                 return (sysarg_t) ENOENT;
     435                return (sys_errno_t) ENOENT;
    436436        }
    437437}
  • kernel/generic/src/synch/mutex.c

    r36f0738 rb7fd2a0  
    8585 *
    8686 */
    87 int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, unsigned int flags)
     87errno_t _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, unsigned int flags)
    8888{
    89         int rc;
     89        errno_t rc;
    9090
    9191        if (mtx->type == MUTEX_PASSIVE && THREAD) {
  • kernel/generic/src/synch/rcu.c

    r36f0738 rb7fd2a0  
    957957                       
    958958                        /* Wait for the GP to complete. */
    959                         int ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
     959                        errno_t ret = _condvar_wait_timeout_spinlock(&rcu.gp_ended, &rcu.gp_lock,
    960960                                SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    961961                       
     
    10131013                spinlock_lock(&rcu.gp_lock);
    10141014
    1015                 int ret = 0;
     1015                errno_t ret = 0;
    10161016                ret = _condvar_wait_timeout_spinlock(&rcu.expedite_now, &rcu.gp_lock,
    10171017                        DETECT_SLEEP_MS * 1000, SYNCH_FLAGS_INTERRUPTIBLE);
  • kernel/generic/src/synch/semaphore.c

    r36f0738 rb7fd2a0  
    7171 *
    7272 */
    73 int _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned int flags)
     73errno_t _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned int flags)
    7474{
    7575        return waitq_sleep_timeout(&sem->wq, usec, flags, NULL);
  • kernel/generic/src/synch/smc.c

    r36f0738 rb7fd2a0  
    4343#include <mm/as.h>
    4444
    45 sysarg_t sys_smc_coherence(uintptr_t va, size_t size)
     45sys_errno_t sys_smc_coherence(uintptr_t va, size_t size)
    4646{
    4747        if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE))
  • kernel/generic/src/synch/smp_memory_barrier.c

    r36f0738 rb7fd2a0  
    5151 * @return Irrelevant.
    5252 */
    53 sysarg_t sys_smp_memory_barrier(void)
     53sys_errno_t sys_smp_memory_barrier(void)
    5454{
    5555        for (unsigned int cpu_id = 0; cpu_id < config.cpu_active; ++cpu_id) {
  • kernel/generic/src/synch/waitq.c

    r36f0738 rb7fd2a0  
    268268 *
    269269 */
    270 int waitq_sleep_timeout(waitq_t *wq, uint32_t usec, unsigned int flags, bool *blocked)
     270errno_t waitq_sleep_timeout(waitq_t *wq, uint32_t usec, unsigned int flags, bool *blocked)
    271271{
    272272        assert((!PREEMPTION_DISABLED) || (PARAM_NON_BLOCKING(flags, usec)));
     
    274274        ipl_t ipl = waitq_sleep_prepare(wq);
    275275        bool nblocked;
    276         int rc = waitq_sleep_timeout_unsafe(wq, usec, flags, &nblocked);
     276        errno_t rc = waitq_sleep_timeout_unsafe(wq, usec, flags, &nblocked);
    277277        waitq_sleep_finish(wq, nblocked, ipl);
    278278
     
    373373 *
    374374 */
    375 int waitq_sleep_timeout_unsafe(waitq_t *wq, uint32_t usec, unsigned int flags, bool *blocked)
     375errno_t waitq_sleep_timeout_unsafe(waitq_t *wq, uint32_t usec, unsigned int flags, bool *blocked)
    376376{
    377377        *blocked = false;
  • kernel/generic/src/synch/workqueue.c

    r36f0738 rb7fd2a0  
    895895       
    896896        while (list_empty(&info->work_queues) && !stop) {
    897                 int ret = _condvar_wait_timeout_irq_spinlock(&info->req_cv,
     897                errno_t ret = _condvar_wait_timeout_irq_spinlock(&info->req_cv,
    898898                        &info->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE);
    899899               
Note: See TracChangeset for help on using the changeset viewer.