Changeset 01900b6 in mainline for uspace/lib/c/generic/task.c


Ignore:
Timestamp:
2020-01-21T15:10:26Z (5 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
51da086
Parents:
f8fb03b
Message:

Use an optional output argument instead of errno to propagate the error

The use of errno is troublesome in all other than top-level library
functions since the value in errno might get overwritten by subsequent
inner calls on the error path (e.g. cleanup, deallocation, etc.). The
optional output argument makes it possible to explicitly ignore the
error code if it is not needed, but still to pass it reliably back to
the original caller.

This change affecs async_connect_me_to(),
async_connect_me_to_blocking(), async_connect_kbox(), service_connect(),
service_connect_blocking() and loader_connect().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/task.c

    rf8fb03b r01900b6  
    181181
    182182        /* Connect to a program loader. */
    183         loader_t *ldr = loader_connect();
     183        errno_t rc;
     184        loader_t *ldr = loader_connect(&rc);
    184185        if (ldr == NULL)
    185                 return EREFUSED;
     186                return rc;
    186187
    187188        bool wait_initialized = false;
     
    189190        /* Get task ID. */
    190191        task_id_t task_id;
    191         errno_t rc = loader_get_task_id(ldr, &task_id);
     192        rc = loader_get_task_id(ldr, &task_id);
    192193        if (rc != EOK)
    193194                goto error;
     
    250251        /* Start a debug session if requested */
    251252        if (rsess != NULL) {
    252                 ksess = async_connect_kbox(task_id);
     253                ksess = async_connect_kbox(task_id, &rc);
    253254                if (ksess == NULL) {
    254255                        /* Most likely debugging support is not compiled in */
    255                         rc = ENOTSUP;
    256256                        goto error;
    257257                }
     
    402402errno_t task_setup_wait(task_id_t id, task_wait_t *wait)
    403403{
    404         async_sess_t *sess_ns = ns_session_get();
     404        errno_t rc;
     405        async_sess_t *sess_ns = ns_session_get(&rc);
    405406        if (sess_ns == NULL)
    406                 return EIO;
     407                return rc;
    407408
    408409        async_exch_t *exch = async_exchange_begin(sess_ns);
     
    484485errno_t task_retval(int val)
    485486{
    486         async_sess_t *sess_ns = ns_session_get();
     487        errno_t rc;
     488        async_sess_t *sess_ns = ns_session_get(&rc);
    487489        if (sess_ns == NULL)
    488                 return EIO;
     490                return rc;
    489491
    490492        async_exch_t *exch = async_exchange_begin(sess_ns);
    491         errno_t rc = (errno_t) async_req_1_0(exch, NS_RETVAL, val);
     493        rc = (errno_t) async_req_1_0(exch, NS_RETVAL, val);
    492494        async_exchange_end(exch);
    493495
Note: See TracChangeset for help on using the changeset viewer.