Changeset 01900b6 in mainline for uspace/srv


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().

Location:
uspace/srv/fs
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/cdfs/cdfs.c

    rf8fb03b r01900b6  
    7575        }
    7676
     77        errno_t rc;
    7778        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    78             INTERFACE_VFS_DRIVER, 0);
     79            INTERFACE_VFS_DRIVER, 0, &rc);
    7980        if (!vfs_sess) {
    80                 printf("%s: Unable to connect to VFS\n", NAME);
     81                printf("%s: Unable to connect to VFS: %s\n", NAME, str_error(rc));
    8182                return -1;
    8283        }
    8384
    84         errno_t rc = fs_register(vfs_sess, &cdfs_vfs_info, &cdfs_ops,
     85        rc = fs_register(vfs_sess, &cdfs_vfs_info, &cdfs_ops,
    8586            &cdfs_libfs_ops);
    8687        if (rc != EOK) {
  • uspace/srv/fs/exfat/exfat.c

    rf8fb03b r01900b6  
    7777
    7878        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    79             INTERFACE_VFS_DRIVER, 0);
     79            INTERFACE_VFS_DRIVER, 0, &rc);
    8080        if (!vfs_sess) {
    81                 printf(NAME ": failed to connect to VFS\n");
     81                printf(NAME ": failed to connect to VFS: %s\n", str_error(rc));
    8282                return -1;
    8383        }
  • uspace/srv/fs/ext4fs/ext4fs.c

    rf8fb03b r01900b6  
    4343#include <ipc/services.h>
    4444#include <str.h>
     45#include <str_error.h>
    4546#include "ext4/ops.h"
    4647#include "../../vfs/vfs.h"
     
    6667        }
    6768
     69        errno_t rc;
    6870        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    69             INTERFACE_VFS_DRIVER, 0);
     71            INTERFACE_VFS_DRIVER, 0, &rc);
    7072        if (!vfs_sess) {
    71                 printf("%s: Failed to connect to VFS\n", NAME);
     73                printf("%s: Failed to connect to VFS: %s\n", NAME, str_error(rc));
    7274                return 2;
    7375        }
    7476
    75         errno_t rc = ext4_global_init();
     77        rc = ext4_global_init();
    7678        if (rc != EOK) {
    77                 printf("%s: Global initialization failed\n", NAME);
     79                printf("%s: Global initialization failed: %s\n", NAME,
     80                    str_error(rc));
    7881                return rc;
    7982        }
     
    8285            &ext4_libfs_ops);
    8386        if (rc != EOK) {
    84                 printf("%s: Failed to register file system\n", NAME);
     87                printf("%s: Failed to register file system: %s\n", NAME,
     88                    str_error(rc));
    8589                return rc;
    8690        }
  • uspace/srv/fs/fat/fat.c

    rf8fb03b r01900b6  
    7777
    7878        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    79             INTERFACE_VFS_DRIVER, 0);
     79            INTERFACE_VFS_DRIVER, 0, &rc);
    8080        if (!vfs_sess) {
    81                 printf(NAME ": failed to connect to VFS\n");
     81                printf(NAME ": failed to connect to VFS: %s\n", str_error(rc));
    8282                return -1;
    8383        }
  • uspace/srv/fs/locfs/locfs.c

    rf8fb03b r01900b6  
    7878        }
    7979
     80        errno_t rc;
    8081        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    81             INTERFACE_VFS_DRIVER, 0);
     82            INTERFACE_VFS_DRIVER, 0, &rc);
    8283        if (!vfs_sess) {
    83                 printf("%s: Unable to connect to VFS\n", NAME);
     84                printf("%s: Unable to connect to VFS: %s\n", NAME, str_error(rc));
    8485                return -1;
    8586        }
    8687
    87         errno_t rc = fs_register(vfs_sess, &locfs_vfs_info, &locfs_ops,
     88        rc = fs_register(vfs_sess, &locfs_vfs_info, &locfs_ops,
    8889            &locfs_libfs_ops);
    8990        if (rc != EOK) {
  • uspace/srv/fs/mfs/mfs.c

    rf8fb03b r01900b6  
    7474
    7575        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    76             INTERFACE_VFS_DRIVER, 0);
    77 
     76            INTERFACE_VFS_DRIVER, 0, &rc);
    7877        if (!vfs_sess) {
    79                 printf(NAME ": failed to connect to VFS\n");
     78                printf(NAME ": failed to connect to VFS: %s\n", str_error(rc));
    8079                rc = errno;
    8180                goto err;
  • uspace/srv/fs/tmpfs/tmpfs.c

    rf8fb03b r01900b6  
    8080        }
    8181
     82        errno_t rc;
    8283        async_sess_t *vfs_sess = service_connect_blocking(SERVICE_VFS,
    83             INTERFACE_VFS_DRIVER, 0);
     84            INTERFACE_VFS_DRIVER, 0, &rc);
    8485        if (!vfs_sess) {
    85                 printf("%s: Unable to connect to VFS\n", NAME);
     86                printf("%s: Unable to connect to VFS: %s\n", NAME, str_error(rc));
    8687                return -1;
    8788        }
    8889
    89         errno_t rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
     90        rc = fs_register(vfs_sess, &tmpfs_vfs_info, &tmpfs_ops,
    9091            &tmpfs_libfs_ops);
    9192        if (rc != EOK) {
  • uspace/srv/fs/udf/udf.c

    rf8fb03b r01900b6  
    7373        }
    7474
     75        errno_t rc;
    7576        async_sess_t *vfs_sess =
    76             service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0);
     77            service_connect_blocking(SERVICE_VFS, INTERFACE_VFS_DRIVER, 0, &rc);
    7778        if (!vfs_sess) {
    78                 log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to connect to VFS");
     79                log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to connect to VFS: %s",
     80                    str_error(rc));
    7981                return 2;
    8082        }
    8183
    82         errno_t rc = fs_register(vfs_sess, &udf_vfs_info, &udf_ops,
     84        rc = fs_register(vfs_sess, &udf_vfs_info, &udf_ops,
    8385            &udf_libfs_ops);
    8486        if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.