Changeset 84a1a54 in mainline for uspace/app


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/app
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/scli.c

    rcde999a r84a1a54  
    120120
    121121        cli_finit(&usr);
    122         return ret;
     122        return EXIT_RC(ret);
    123123}
  • uspace/app/corecfg/corecfg.c

    rcde999a r84a1a54  
    3636#include <errno.h>
    3737#include <stdio.h>
     38#include <stdlib.h>
    3839
    3940#define NAME "corecfg"
     
    7677                return corecfg_print();
    7778        else if (str_cmp(argv[1], "enable") == 0)
    78                 return corecfg_set_enable(true);
     79                return EXIT_RC(corecfg_set_enable(true));
    7980        else if (str_cmp(argv[1], "disable") == 0)
    80                 return corecfg_set_enable(false);
     81                return EXIT_RC(corecfg_set_enable(false));
    8182        else {
    8283                printf("%s: Unknown command '%s'.\n", NAME, argv[1]);
  • uspace/app/date/date.c

    rcde999a r84a1a54  
    191191        free(svc_name);
    192192        free(svc_ids);
    193         return rc;
     193        return EXIT_RC(rc);
    194194}
    195195
  • uspace/app/dnscfg/dnscfg.c

    rcde999a r84a1a54  
    128128{
    129129        if ((argc < 2) || (str_cmp(argv[1], "get-ns") == 0))
    130                 return dnscfg_print();
     130                return EXIT_RC(dnscfg_print());
    131131        else if (str_cmp(argv[1], "set-ns") == 0)
    132                 return dnscfg_set_ns(argc - 2, argv + 2);
     132                return EXIT_RC(dnscfg_set_ns(argc - 2, argv + 2));
    133133        else if (str_cmp(argv[1], "unset-ns") == 0)
    134                 return dnscfg_unset_ns();
     134                return EXIT_RC(dnscfg_unset_ns());
    135135        else {
    136136                printf("%s: Unknown command '%s'.\n", NAME, argv[1]);
  • uspace/app/dnsres/dnsres.c

    rcde999a r84a1a54  
    8181        if (rc != EOK) {
    8282                printf("%s: Error resolving '%s'.\n", NAME, hname);
    83                 return rc;
     83                return EXIT_RC(rc);
    8484        }
    8585       
     
    8989                dnsr_hostinfo_destroy(hinfo);
    9090                printf("%s: Error formatting address.\n", NAME);
    91                 return rc;
     91                return EXIT_RC(rc);
    9292        }
    9393       
  • uspace/app/download/main.c

    rcde999a r84a1a54  
    240240        if (ofile != NULL && fclose(ofile) != 0) {
    241241                printf("Error writing '%s'.\n", ofname);
    242                 return EIO;
    243         }
    244 
    245         return EOK;
     242                return EXIT_RC(EIO);
     243        }
     244
     245        return 0;
    246246error:
    247247        free(buf);
     
    252252        if (ofile != NULL)
    253253                fclose(ofile);
    254         return rc;
     254        return EXIT_RC(rc);
    255255}
    256256
  • uspace/app/getterm/getterm.c

    rcde999a r84a1a54  
    3737#include <stdint.h>
    3838#include <stdio.h>
     39#include <stdlib.h>
    3940#include <task.h>
    4041#include <str_error.h>
     
    137138                        printf("%s: Error waiting on %s (%s)\n", APP_NAME, term,
    138139                            str_error(rc));
    139                         return rc;
     140                        return EXIT_RC(rc);
    140141                }
    141142        }
     
    174175                printf("%s: Error spawning %s (%s)\n", APP_NAME, cmd,
    175176                    str_error(rc));
    176                 return rc;
     177                return EXIT_RC(rc);
    177178        }
    178179       
     
    183184                printf("%s: Error waiting for %s (%s)\n", APP_NAME, cmd,
    184185                    str_error(rc));
    185                 return rc;
     186                return EXIT_RC(rc);
    186187        }
    187188       
  • uspace/app/kio/kio.c

    rcde999a r84a1a54  
    191191                fprintf(stderr, "%s: Unable to get number of kio pages\n",
    192192                    NAME);
    193                 return rc;
     193                return EXIT_RC(rc);
    194194        }
    195195       
     
    199199                fprintf(stderr, "%s: Unable to get kio physical address\n",
    200200                    NAME);
    201                 return rc;
     201                return EXIT_RC(rc);
    202202        }
    203203       
     
    209209        if (rc != EOK) {
    210210                fprintf(stderr, "%s: Unable to map kio\n", NAME);
    211                 return rc;
     211                return EXIT_RC(rc);
    212212        }
    213213       
     
    217217                fprintf(stderr, "%s: Unable to register kio notifications\n",
    218218                    NAME);
    219                 return rc;
     219                return EXIT_RC(rc);
    220220        }
    221221       
     
    224224                fprintf(stderr, "%s: Unable to create consumer fibril\n",
    225225                    NAME);
    226                 return ENOMEM;
     226                return EXIT_RC(ENOMEM);
    227227        }
    228228       
     
    230230        if (!input) {
    231231                fprintf(stderr, "%s: Could not create input\n", NAME);
    232                 return ENOMEM;
     232                return EXIT_RC(ENOMEM);
    233233        }
    234234
     
    253253                rc = EOK;
    254254
    255         return EOK;
     255        return EXIT_RC(rc);
    256256}
    257257
  • uspace/app/mkbd/main.c

    rcde999a r84a1a54  
    222222                printf("Device not found or not of USB kind: %s.\n",
    223223                    str_error(rc));
    224                 return rc;
     224                return EXIT_RC(rc);
    225225        }
    226226       
     
    229229                printf(NAME ": failed to connect to the device (handle %"
    230230                       PRIun "): %s.\n", dev_handle, str_error(errno));
    231                 return errno;
     231                return EXIT_RC(errno);
    232232        }
    233233       
     
    239239                printf(NAME ": failed to get path (handle %"
    240240                       PRIun "): %s.\n", dev_handle, str_error(errno));
    241                 return ENOMEM;
     241                return EXIT_RC(ENOMEM);
    242242        }
    243243       
     
    250250                printf("Failed to initialize report parser: %s\n",
    251251                    str_error(rc));
    252                 return rc;
     252                return EXIT_RC(rc);
    253253        }
    254254       
     
    259259        if (rc != EOK) {
    260260                printf("Failed to get event length: %s.\n", str_error(rc));
    261                 return rc;
     261                return EXIT_RC(rc);
    262262        }
    263263       
     
    266266                printf("Out of memory.\n");
    267267                // TODO: hangup phone?
    268                 return ENOMEM;
     268                return EXIT_RC(ENOMEM);
    269269        }
    270270       
  • uspace/app/nic/nic.c

    rcde999a r84a1a54  
    413413        async_sess_t *sess;
    414414        nic_address_t addr;
    415         int rc, idx;
     415        int rc;
     416        int idx;
    416417
    417418        sess = get_nic_by_index(i);
     
    543544
    544545                if (!str_cmp(argv[2], "addr"))
    545                         return nic_set_addr(index, argv[3]);
     546                        return EXIT_RC(nic_set_addr(index, argv[3]));
    546547
    547548                if (!str_cmp(argv[2], "speed"))
    548                         return nic_set_speed(index, argv[3]);
     549                        return EXIT_RC(nic_set_speed(index, argv[3]));
    549550
    550551                if (!str_cmp(argv[2], "duplex"))
    551                         return nic_set_duplex(index, argv[3]);
     552                        return EXIT_RC(nic_set_duplex(index, argv[3]));
    552553
    553554                if (!str_cmp(argv[2], "auto"))
    554                         return nic_set_autoneg(index);
     555                        return EXIT_RC(nic_set_autoneg(index));
    555556
    556557                if (!str_cmp(argv[2], "unicast"))
    557                         return nic_set_rx_unicast(index, argv[3]);
     558                        return EXIT_RC(nic_set_rx_unicast(index, argv[3]));
    558559
    559560                if (!str_cmp(argv[2], "multicast"))
    560                         return nic_set_rx_multicast(index, argv[3]);
     561                        return EXIT_RC(nic_set_rx_multicast(index, argv[3]));
    561562
    562563                if (!str_cmp(argv[2], "broadcast"))
    563                         return nic_set_rx_broadcast(index, argv[3]);
     564                        return EXIT_RC(nic_set_rx_broadcast(index, argv[3]));
    564565
    565566        } else {
  • uspace/app/sysinfo/sysinfo.c

    rcde999a r84a1a54  
    9090        fputs("')\n", stdout);
    9191       
    92         return EOK;
     92        return 0;
    9393}
    9494
     
    109109        fputs("')\n", stdout);
    110110       
    111         return EOK;
     111        return 0;
    112112}
    113113
     
    182182                        break;
    183183                case SYSINFO_VAL_VAL:
    184                         rc = print_item_val(ipath);
     184                        rc = EXIT_RC(print_item_val(ipath));
    185185                        break;
    186186                case SYSINFO_VAL_DATA:
  • uspace/app/sysinst/sysinst.c

    rcde999a r84a1a54  
    387387{
    388388        const char *dev = DEFAULT_DEV;
    389         return sysinst_install(dev);
     389        return EXIT_RC(sysinst_install(dev));
    390390}
    391391
  • uspace/app/vuhid/main.c

    rcde999a r84a1a54  
    238238                printf("Unable to start communication with VHCD `%s': %s.\n",
    239239                    controller, str_error(rc));
    240                 return rc;
     240                return EXIT_RC(rc);
    241241        }
    242242       
  • uspace/app/websrv/websrv.c

    rcde999a r84a1a54  
    450450                        rc = parse_option(argc, argv, &i);
    451451                        if (rc != EOK)
    452                                 return rc;
     452                                return EXIT_RC(rc);
    453453                } else {
    454454                        usage();
    455                         return EINVAL;
     455                        return EXIT_RC(EINVAL);
    456456                }
    457457        }
  • uspace/app/wifi_supplicant/wifi_supplicant.c

    rcde999a r84a1a54  
    293293        if (argc == 2) {
    294294                if (!str_cmp(argv[1], "list"))
    295                         return wifi_list();
     295                        return EXIT_RC(wifi_list());
    296296        } else if (argc > 2) {
    297297                uint32_t index;
     
    300300                        printf("%s: Invalid argument.\n", NAME);
    301301                        print_syntax();
    302                         return EINVAL;
     302                        return EXIT_RC(EINVAL);
    303303                }
    304304               
     
    309309                                        now = true;
    310310                       
    311                         return wifi_scan(index, now);
     311                        return EXIT_RC(wifi_scan(index, now));
    312312                } else if (!str_cmp(argv[1], "connect")) {
    313313                        char *pass = NULL;
     
    316316                                        pass = argv[4];
    317317                               
    318                                 return wifi_connect(index, argv[3], pass);
     318                                return EXIT_RC(wifi_connect(index, argv[3], pass));
    319319                        }
    320320                } else if (!str_cmp(argv[1], "disconnect"))
    321                         return wifi_disconnect(index);
     321                        return EXIT_RC(wifi_disconnect(index));
    322322        }
    323323       
    324324        print_syntax();
    325325       
    326         return EOK;
     326        return 0;
    327327}
    328328
Note: See TracChangeset for help on using the changeset viewer.