Changeset 84a1a54 in mainline for uspace/srv


Ignore:
Timestamp:
2018-01-04T20:47:53Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
facacc71
Parents:
cde999a
Message:

Wrap returns of errno from main() with EXIT_RC().

Returns of error code from main() prevent type checking when errno_t
and int are considered incompatible. In order to avoid the philosophical
discussion of what should and shouldn't be returned for main(), we simply
wrap the error values and leave the answer to the question for future
generations to decide.

Location:
uspace/srv
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/main.c

    rcde999a r84a1a54  
    8080                log_fatal("Failed to initialize hound structure: %s",
    8181                    str_error(ret));
    82                 return -ret;
     82                return EXIT_RC(ret);
    8383        }
    8484
     
    9191        if (ret != EOK) {
    9292                log_fatal("Failed to register server: %s", str_error(ret));
    93                 return -ret;
     93                return EXIT_RC(ret);
    9494        }
    9595
     
    9999                    str_error(ret));
    100100                hound_server_unregister(id);
    101                 return -ret;
     101                return EXIT_RC(ret);
    102102        }
    103103        log_info("Running with service id %" PRIun, id);
  • uspace/srv/bd/file_bd/file_bd.c

    rcde999a r84a1a54  
    4747#include <stddef.h>
    4848#include <stdint.h>
     49#include <stdlib.h>
    4950#include <errno.h>
    5051#include <str_error.h>
     
    137138                printf("%s: Unable to register device '%s': %s.\n",
    138139                    NAME, device_name, str_error(rc));
    139                 return rc;
     140                return EXIT_RC(rc);
    140141        }
    141142
     
    143144        if (rc != EOK) {
    144145                printf("%s: Failed resolving category 'disk': %s\n", NAME, str_error(rc));
    145                 return rc;
     146                return EXIT_RC(rc);
    146147        }
    147148
     
    150151                printf("%s: Failed adding %s to category: %s",
    151152                    NAME, device_name, str_error(rc));
    152                 return rc;
     153                return EXIT_RC(rc);
    153154        }
    154155
  • uspace/srv/bd/sata_bd/sata_bd.c

    rcde999a r84a1a54  
    253253        if (rc != EOK) {
    254254                printf(NAME ": Unable to register driver: %s.\n", str_error(rc));
    255                 return rc;
     255                return EXIT_RC(rc);
    256256        }
    257257       
    258258        rc = get_sata_disks();
    259259        if (rc != EOK) {
    260                 // TODO: log the error
    261                 return rc;
     260                printf(NAME ": Cannot find SATA disks: %s.\n", str_error(rc));
     261                return EXIT_RC(rc);
    262262        }
    263263
     
    265265        if (rc != EOK) {
    266266                printf("%s: Failed resolving category 'disk': %s.\n", NAME, str_error(rc));
    267                 return rc;
     267                return EXIT_RC(rc);
    268268        }
    269269
     
    274274                if (rc != EOK) {
    275275                        printf(NAME ": Unable to register device %s: %s\n", name, str_error(rc));
    276                         return rc;
     276                        return EXIT_RC(rc);
    277277                }
    278278
     
    281281                        printf("%s: Failed adding %s to category: %s.",
    282282                            NAME, disk[i].dev_name, str_error(rc));
    283                         return rc;
     283                        return EXIT_RC(rc);
    284284                }
    285285        }
  • uspace/srv/clipboard/clipboard.c

    rcde999a r84a1a54  
    190190        if (rc != EOK) {
    191191                printf("%s: Failed registering server: %s\n", NAME, str_error(rc));
    192                 return rc;
     192                return EXIT_RC(rc);
    193193        }
    194194       
     
    196196        if (rc != EOK) {
    197197                printf("%s: Failed registering service : %s\n", NAME, str_error(rc));
    198                 return rc;
     198                return EXIT_RC(rc);
    199199        }
    200200       
  • uspace/srv/devman/main.c

    rcde999a r84a1a54  
    320320        if (rc != EOK) {
    321321                printf("%s: Error initializing logging subsystem: %s\n", NAME, str_error(rc));
    322                 return rc;
     322                return EXIT_RC(rc);
    323323        }
    324324       
     
    332332        if (rc != EOK) {
    333333                printf("%s: Error creating DDF driver port: %s\n", NAME, str_error(rc));
    334                 return rc;
     334                return EXIT_RC(rc);
    335335        }
    336336       
     
    339339        if (rc != EOK) {
    340340                printf("%s: Error creating DDF client port: %s\n", NAME, str_error(rc));
    341                 return rc;
     341                return EXIT_RC(rc);
    342342        }
    343343       
     
    346346        if (rc != EOK) {
    347347                printf("%s: Error creating devman device port: %s\n", NAME, str_error(rc));
    348                 return rc;
     348                return EXIT_RC(rc);
    349349        }
    350350       
     
    353353        if (rc != EOK) {
    354354                printf("%s: Error creating devman parent port: %s\n", NAME, str_error(rc));
    355                 return rc;
     355                return EXIT_RC(rc);
    356356        }
    357357       
     
    367367        if (rc != EOK) {
    368368                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering as a service: %s", str_error(rc));
    369                 return rc;
     369                return EXIT_RC(rc);
    370370        }
    371371       
  • uspace/srv/fs/cdfs/cdfs.c

    rcde999a r84a1a54  
    4343#include <str_error.h>
    4444#include <stdio.h>
     45#include <stdlib.h>
    4546#include <libfs.h>
    4647#include "cdfs.h"
     
    8586        if (rc != EOK) {
    8687                printf("%s: Failed to register file system: %s\n", NAME, str_error(rc));
    87                 return rc;
     88                return EXIT_RC(rc);
    8889        }
    8990       
  • uspace/srv/fs/exfat/exfat.c

    rcde999a r84a1a54  
    4646#include <task.h>
    4747#include <stdio.h>
     48#include <stdlib.h>
    4849#include <libfs.h>
    4950#include "../../vfs/vfs.h"
     
    9798err:
    9899        printf(NAME ": Failed to register file system: %s\n", str_error(rc));
    99         return rc;
     100        return EXIT_RC(rc);
    100101}
    101102
  • uspace/srv/fs/ext4fs/ext4fs.c

    rcde999a r84a1a54  
    4040#include <ns.h>
    4141#include <stdio.h>
     42#include <stdlib.h>
    4243#include <task.h>
    4344#include <ipc/services.h>
     
    7576        if (rc != EOK) {
    7677                printf("%s: Global initialization failed\n", NAME);
    77                 return rc;
     78                return EXIT_RC(rc);
    7879        }
    7980       
     
    8283        if (rc != EOK) {
    8384                printf("%s: Failed to register file system\n", NAME);
    84                 return rc;
     85                return EXIT_RC(rc);
    8586        }
    8687       
  • uspace/srv/fs/fat/fat.c

    rcde999a r84a1a54  
    4646#include <task.h>
    4747#include <stdio.h>
     48#include <stdlib.h>
    4849#include <libfs.h>
    4950#include "../../vfs/vfs.h"
     
    9798err:
    9899        printf(NAME ": Failed to register file system: %s\n", str_error(rc));
    99         return rc;
     100        return EXIT_RC(rc);
    100101}
    101102
  • uspace/srv/fs/locfs/locfs.c

    rcde999a r84a1a54  
    4040
    4141#include <stdio.h>
     42#include <stdlib.h>
    4243#include <ipc/services.h>
    4344#include <ns.h>
     
    8990        if (rc != EOK) {
    9091                printf("%s: Failed to register file system: %s\n", NAME, str_error(rc));
    91                 return rc;
     92                return EXIT_RC(rc);
    9293        }
    9394       
  • uspace/srv/fs/mfs/mfs.c

    rcde999a r84a1a54  
    100100err:
    101101        printf(NAME ": Failed to register file system: %s\n", str_error(rc));
    102         return rc;
     102        return EXIT_RC(rc);
    103103}
    104104
  • uspace/srv/fs/tmpfs/tmpfs.c

    rcde999a r84a1a54  
    4848#include <str_error.h>
    4949#include <stdio.h>
     50#include <stdlib.h>
    5051#include <task.h>
    5152#include <libfs.h>
     
    9192        if (rc != EOK) {
    9293                printf(NAME ": Failed to register file system: %s\n", str_error(rc));
    93                 return rc;
     94                return EXIT_RC(rc);
    9495        }
    9596       
  • uspace/srv/fs/udf/udf.c

    rcde999a r84a1a54  
    4242#include <errno.h>
    4343#include <str_error.h>
     44#include <stdlib.h>
    4445#include <task.h>
    4546#include <libfs.h>
     
    9899err:
    99100        log_msg(LOG_DEFAULT, LVL_FATAL, "Failed to register file system: %s", str_error(rc));
    100         return rc;
     101        return EXIT_RC(rc);
    101102}
    102103
  • uspace/srv/hid/compositor/compositor.c

    rcde999a r84a1a54  
    22542254        if (rc != EOK) {
    22552255                printf("%s: Unable to register server (%s)\n", NAME, str_error(rc));
    2256                 return -1;
     2256                return rc;
    22572257        }
    22582258       
     
    22722272        char winreg[LOC_NAME_MAXLEN + 1];
    22732273        snprintf(winreg, LOC_NAME_MAXLEN, "%s%s/winreg", NAMESPACE, server_name);
    2274         if (loc_service_register(winreg, &winreg_id) != EOK) {
     2274        rc = loc_service_register(winreg, &winreg_id);
     2275        if (rc != EOK) {
    22752276                printf("%s: Unable to register service %s\n", NAME, winreg);
    2276                 return -1;
     2277                return rc;
    22772278        }
    22782279       
     
    23152316        int rc = compositor_srv_init(argv[1], argv[2]);
    23162317        if (rc != EOK)
    2317                 return rc;
     2318                return EXIT_RC(rc);
    23182319       
    23192320        printf("%s: Accepting connections\n", NAME);
  • uspace/srv/hid/input/input.c

    rcde999a r84a1a54  
    869869        if (rc != EOK) {
    870870                printf("%s: Unable to register server\n", NAME);
    871                 return rc;
     871                return EXIT_RC(rc);
    872872        }
    873873       
     
    876876        if (rc != EOK) {
    877877                printf("%s: Unable to register service %s\n", NAME, argv[1]);
    878                 return rc;
     878                return EXIT_RC(rc);
    879879        }
    880880       
  • uspace/srv/hid/isdv4_tablet/main.c

    rcde999a r84a1a54  
    315315        if (rc != EOK) {
    316316                printf("%s: Unable to register driver.\n", NAME);
    317                 return rc;
     317                return EXIT_RC(rc);
    318318        }
    319319
    320320        service_id_t service_id;
    321321        char *service_name;
    322         rc = asprintf(&service_name, "mouse/isdv4-%" PRIun, svc_id);
    323         if (rc < 0) {
     322        if (asprintf(&service_name, "mouse/isdv4-%" PRIun, svc_id) < 0) {
    324323                printf(NAME ": Unable to create service name\n");
    325                 return rc;
     324                return EXIT_RC(ENOMEM);
    326325        }
    327326
     
    329328        if (rc != EOK) {
    330329                printf(NAME ": Unable to register service %s.\n", service_name);
    331                 return rc;
     330                return EXIT_RC(rc);
    332331        }
    333332
  • uspace/srv/hid/output/output.c

    rcde999a r84a1a54  
    470470        if (rc != EOK) {
    471471                printf("%s: Unable to register driver\n", NAME);
    472                 return rc;
     472                return EXIT_RC(rc);
    473473        }
    474474       
     
    477477        if (rc != EOK) {
    478478                printf("%s: Unable to register service %s\n", NAME, argv[1]);
    479                 return rc;
     479                return EXIT_RC(rc);
    480480        }
    481481       
  • uspace/srv/hid/remcons/remcons.c

    rcde999a r84a1a54  
    353353        if (rc != EOK) {
    354354                fprintf(stderr, "%s: Unable to register server\n", NAME);
    355                 return rc;
     355                return EXIT_RC(rc);
    356356        }
    357357
     
    359359        if (rc != EOK) {
    360360                fprintf(stderr, "%s: Error initializing TCP.\n", NAME);
    361                 return rc;
     361                return EXIT_RC(rc);
    362362        }
    363363
     
    369369        if (rc != EOK) {
    370370                fprintf(stderr, "%s: Error creating listener.\n", NAME);
    371                 return rc;
     371                return EXIT_RC(rc);
    372372        }
    373373
  • uspace/srv/hid/rfb/main.c

    rcde999a r84a1a54  
    220220        if (rc != EOK) {
    221221                printf("%s: Unable to register server.\n", NAME);
    222                 return rc;
     222                return EXIT_RC(rc);
    223223        }
    224224
    225225        char *service_name;
    226         rc = asprintf(&service_name, "rfb/%s", rfb_name);
    227         if (rc < 0) {
     226        if (asprintf(&service_name, "rfb/%s", rfb_name) < 0) {
    228227                printf(NAME ": Unable to create service name\n");
    229                 return rc;
     228                return EXIT_RC(ENOMEM);
    230229        }
    231230
     
    235234        if (rc != EOK) {
    236235                printf(NAME ": Unable to register service %s.\n", service_name);
    237                 return rc;
     236                return EXIT_RC(rc);
    238237        }
    239238       
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    rcde999a r84a1a54  
    8888        if (rc != EOK) {
    8989                printf("%s: Unable to register driver.\n", NAME);
    90                 return rc;
     90                return EXIT_RC(rc);
    9191        }
    9292
     
    9595                return -1;
    9696
    97         if (s3c24xx_ts_init(ts) != EOK)
     97        if (s3c24xx_ts_init(ts) != 0)
    9898                return -1;
    9999
     
    141141        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
    142142
    143         return EOK;
     143        return 0;
    144144}
    145145
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    rcde999a r84a1a54  
    8585        if (rc != EOK) {
    8686                printf("%s: Unable to register server.\n", NAME);
    87                 return rc;
     87                return EXIT_RC(rc);
    8888        }
    8989
     
    9292                return -1;
    9393
    94         if (s3c24xx_uart_init(uart) != EOK)
     94        if (s3c24xx_uart_init(uart) != 0)
    9595                return -1;
    9696
     
    187187        uart->cds.sarg = uart;
    188188
    189         return EOK;
     189        return 0;
    190190}
    191191
  • uspace/srv/klog/klog.c

    rcde999a r84a1a54  
    213213        if (rc != EOK) {
    214214                fprintf(stderr, "%s: Unable to initialize log\n", NAME);
    215                 return rc;
     215                return EXIT_RC(rc);
    216216        }
    217217       
     
    232232                log_msg(LOG_DEFAULT, LVL_ERROR,
    233233                    "Unable to register klog notifications");
    234                 return rc;
     234                return EXIT_RC(rc);
    235235        }
    236236       
     
    239239                log_msg(LOG_DEFAULT, LVL_ERROR,
    240240                    "Unable to create consumer fibril");
    241                 return ENOMEM;
     241                return EXIT_RC(ENOMEM);
    242242        }
    243243       
  • uspace/srv/loader/main.c

    rcde999a r84a1a54  
    397397        int rc = ns_intro(id);
    398398        if (rc != EOK)
    399                 return rc;
     399                return EXIT_RC(rc);
    400400       
    401401        /* Create port */
     
    403403        rc = async_create_port(INTERFACE_LOADER, ldr_connection, NULL, &port);
    404404        if (rc != EOK)
    405                 return rc;
     405                return EXIT_RC(rc);
    406406       
    407407        /* Register at naming service. */
    408408        rc = service_register(SERVICE_LOADER);
    409409        if (rc != EOK)
    410                 return rc;
     410                return EXIT_RC(rc);
    411411       
    412412        async_manager();
  • uspace/srv/locsrv/locsrv.c

    rcde999a r84a1a54  
    15321532        if (rc != EOK) {
    15331533                printf("%s: Error while creating supplier port: %s\n", NAME, str_error(rc));
    1534                 return rc;
     1534                return EXIT_RC(rc);
    15351535        }
    15361536       
     
    15391539        if (rc != EOK) {
    15401540                printf("%s: Error while creating consumer port: %s\n", NAME, str_error(rc));
    1541                 return rc;
     1541                return EXIT_RC(rc);
    15421542        }
    15431543       
     
    15491549        if (rc != EOK) {
    15501550                printf("%s: Error while registering service: %s\n", NAME, str_error(rc));
    1551                 return rc;
     1551                return EXIT_RC(rc);
    15521552        }
    15531553       
  • uspace/srv/logger/main.c

    rcde999a r84a1a54  
    7474        if (rc != EOK) {
    7575                printf("%s: Error while creating control port: %s\n", NAME, str_error(rc));
    76                 return rc;
     76                return EXIT_RC(rc);
    7777        }
    7878       
     
    8181        if (rc != EOK) {
    8282                printf("%s: Error while creating writer port: %s\n", NAME, str_error(rc));
    83                 return rc;
     83                return EXIT_RC(rc);
    8484        }
    8585       
  • uspace/srv/net/loopip/loopip.c

    rcde999a r84a1a54  
    253253        if (rc != EOK) {
    254254                printf("%s: Failed to initialize logging: %s.\n", NAME, str_error(rc));
    255                 return rc;
     255                return EXIT_RC(rc);
    256256        }
    257257       
     
    259259        if (rc != EOK) {
    260260                printf("%s: Failed to initialize loopip: %s.\n", NAME, str_error(rc));
    261                 return rc;
     261                return EXIT_RC(rc);
    262262        }
    263263       
  • uspace/srv/net/slip/slip.c

    rcde999a r84a1a54  
    421421        if (argc != 3) {
    422422                usage();
    423                 return EINVAL;
     423                return EXIT_RC(EINVAL);
    424424        }
    425425
     
    427427        if (rc != EOK) {
    428428                printf(NAME ": failed to initialize log\n");
    429                 return rc;
     429                return EXIT_RC(rc);
    430430        }
    431431
  • uspace/srv/ns/ns.c

    rcde999a r84a1a54  
    4242#include <abi/ipc/interfaces.h>
    4343#include <stdio.h>
     44#include <stdlib.h>
    4445#include <errno.h>
    4546#include <macros.h>
     
    133134        int rc = service_init();
    134135        if (rc != EOK)
    135                 return rc;
     136                return EXIT_RC(rc);
    136137       
    137138        rc = clonable_init();
    138139        if (rc != EOK)
    139                 return rc;
     140                return EXIT_RC(rc);
    140141       
    141142        rc = task_init();
    142143        if (rc != EOK)
    143                 return rc;
     144                return EXIT_RC(rc);
    144145       
    145146        async_set_fallback_port_handler(ns_connection, NULL);
  • uspace/srv/test/chardev-test/main.c

    rcde999a r84a1a54  
    3535#include <mem.h>
    3636#include <stdio.h>
     37#include <stdlib.h>
    3738#include <task.h>
    3839
     
    114115        if (rc != EOK) {
    115116                printf("%s: Failed registering server.: %s\n", NAME, str_error(rc));
    116                 return rc;
     117                return EXIT_RC(rc);
    117118        }
    118119
     
    132133        if (rc != EOK) {
    133134                printf("%s: Failed registering service.: %s\n", NAME, str_error(rc));
    134                 return rc;
     135                return EXIT_RC(rc);
    135136        }
    136137
     
    138139        if (rc != EOK) {
    139140                printf("%s: Failed registering service.: %s\n", NAME, str_error(rc));
    140                 return rc;
     141                return EXIT_RC(rc);
    141142        }
    142143
     
    144145        if (rc != EOK) {
    145146                printf("%s: Failed registering service.: %s\n", NAME, str_error(rc));
    146                 return rc;
     147                return EXIT_RC(rc);
    147148        }
    148149
  • uspace/srv/vfs/vfs.c

    rcde999a r84a1a54  
    9898                printf("%s: Failed to initialize VFS node hash table\n",
    9999                    NAME);
    100                 return ENOMEM;
     100                return EXIT_RC(ENOMEM);
    101101        }
    102102       
     
    108108        if (plb == AS_MAP_FAILED) {
    109109                printf("%s: Cannot create address space area\n", NAME);
    110                 return ENOMEM;
     110                return EXIT_RC(ENOMEM);
    111111        }
    112112        memset(plb, 0, PLB_SIZE);
     
    125125        if (rc != EOK) {
    126126                printf("%s: Cannot create pager port: %s\n", NAME, str_error(rc));
    127                 return rc;
     127                return EXIT_RC(rc);
    128128        }
    129129
     
    145145        if (rc != EOK) {
    146146                printf("%s: Cannot register VFS service: %s\n", NAME, str_error(rc));
    147                 return rc;
     147                return EXIT_RC(rc);
    148148        }
    149149       
Note: See TracChangeset for help on using the changeset viewer.