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


Ignore:
Timestamp:
2020-01-21T15:10:26Z (4 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/loader.c

    rf8fb03b r01900b6  
    4646#include "private/loader.h"
    4747
    48 /** Connect to a new program loader.
    49  *
    50  * Spawns a new program loader task and returns the connection structure.
     48/** Spawn a new program loader.
     49 *
     50 * Spawn a new program loader task. The loader then independetly
     51 * connects to the naming service.
    5152 *
    5253 * @param name Symbolic name to set on the newly created task.
    5354 *
    5455 * @return Error code.
     56 *
    5557 */
    5658errno_t loader_spawn(const char *name)
     
    6062}
    6163
    62 loader_t *loader_connect(void)
     64/** Connect to a program loader.
     65 *
     66 * @param rc Placeholder for return code. Unused if NULL.
     67 *
     68 * @return Loader structure.
     69 *
     70 */
     71loader_t *loader_connect(errno_t *rc)
    6372{
    6473        loader_t *ldr = malloc(sizeof(loader_t));
     
    6776
    6877        async_sess_t *sess =
    69             service_connect_blocking(SERVICE_LOADER, INTERFACE_LOADER, 0);
     78            service_connect_blocking(SERVICE_LOADER, INTERFACE_LOADER, 0, rc);
    7079        if (sess == NULL) {
    7180                free(ldr);
Note: See TracChangeset for help on using the changeset viewer.