Changeset b7fd2a0 in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2018-01-13T03:10:29Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

Location:
uspace/app/bdsh/cmds
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtins/batch/batch.c

    r36f0738 rb7fd2a0  
    8585        }
    8686
    87         int rc = EOK;
     87        errno_t rc = EOK;
    8888        FILE *batch = fopen(argv[1], "r");
    8989        if (batch == NULL) {
  • uspace/app/bdsh/cmds/builtins/cd/cd.c

    r36f0738 rb7fd2a0  
    5151static bool previous_directory_set = false;
    5252
    53 static int chdir_and_remember(const char *new_dir)
     53static errno_t chdir_and_remember(const char *new_dir)
    5454{
    5555
    56         int rc = vfs_cwd_get(previous_directory_tmp, PATH_MAX);
     56        errno_t rc = vfs_cwd_get(previous_directory_tmp, PATH_MAX);
    5757        previous_directory_valid = (rc == EOK);
    5858        previous_directory_set = true;
     
    8686{
    8787        int argc;
    88         int rc = EOK;
     88        errno_t rc = EOK;
    8989
    9090        argc = cli_count_args(argv);
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r36f0738 rb7fd2a0  
    187187        off64_t file_size = 0, length = 0;
    188188        aoff64_t pos = 0;
    189         int rc;
     189        errno_t rc;
    190190
    191191        bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
     
    196196                blen = STR_BOUNDS(1);
    197197        } else {
    198                 int rc = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ, &fd);
     198                errno_t rc = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ, &fd);
    199199                if (rc != EOK) {
    200200                        fd = -1;
     
    316316        bool tailFirst = false;
    317317        sysarg_t rows, cols;
    318         int rc;
     318        errno_t rc;
    319319       
    320320        /*
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    r36f0738 rb7fd2a0  
    7070}
    7171
    72 static int cmp_files(const char *fn0, const char *fn1)
     72static errno_t cmp_files(const char *fn0, const char *fn1)
    7373{
    74         int rc = EOK;
     74        errno_t rc = EOK;
    7575        const char *fn[2] = {fn0, fn1};
    7676        int fd[2] = {-1, -1};
     
    117117int cmd_cmp(char **argv)
    118118{
    119         int rc;
     119        errno_t rc;
    120120        unsigned int argc;
    121121        int c, opt_ind;
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r36f0738 rb7fd2a0  
    8282        struct stat s;
    8383
    84         int r = vfs_stat_path(path, &s);
     84        errno_t r = vfs_stat_path(path, &s);
    8585
    8686        if (r != EOK)
     
    176176}
    177177
    178 static int do_copy(const char *src, const char *dest,
     178static errno_t do_copy(const char *src, const char *dest,
    179179    size_t blen, int vb, int recursive, int force, int interactive)
    180180{
    181         int rc = EOK;
     181        errno_t rc = EOK;
    182182        char dest_path[PATH_MAX];
    183183        char src_path[PATH_MAX];
     
    388388        int fd1, fd2;
    389389        size_t rbytes, wbytes;
    390         int rc;
     390        errno_t rc;
    391391        off64_t total;
    392392        char *buff = NULL;
     
    479479        int force = 0, interactive = 0;
    480480        int c, opt_ind;
    481         int ret;
     481        errno_t ret;
    482482
    483483        con = console_init(stdin, stdout);
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r36f0738 rb7fd2a0  
    135135        int i;
    136136        int nbdirs = 0;
    137         int rc;
     137        errno_t rc;
    138138        int len;
    139139        char *buff;
  • uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

    r36f0738 rb7fd2a0  
    9494
    9595        int ret = 0;
    96         int rc;
     96        errno_t rc;
    9797
    9898        if (!create_parents) {
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r36f0738 rb7fd2a0  
    8989 * @return      EOK on success or an error code
    9090 */
    91 static int read_size(const char *str, size_t *rsize)
     91static errno_t read_size(const char *str, size_t *rsize)
    9292{
    9393        size_t number, unit;
     
    123123        size_t to_write;
    124124        size_t nwritten;
    125         int rc;
     125        errno_t rc;
    126126        char *file_name;
    127127        void *buffer;
  • uspace/app/bdsh/cmds/modules/mount/mount.c

    r36f0738 rb7fd2a0  
    7878        mtab_ent_t *old_ent = NULL;
    7979        char *svc_name;
    80         int rc;
     80        errno_t rc;
    8181
    8282        vfs_get_mtab_list(&mtab_list);
     
    109109static void print_fstypes(void)
    110110{
    111         int rc;
     111        errno_t rc;
    112112        vfs_fstypes_t fstypes;
    113113        char **p;
     
    132132        const char *mopts = "";
    133133        const char *dev = "";
    134         int rc;
     134        errno_t rc;
    135135        int c, opt_ind;
    136136        unsigned int instance = 0;
  • uspace/app/bdsh/cmds/modules/mv/mv.c

    r36f0738 rb7fd2a0  
    5252{
    5353        unsigned int argc;
    54         int rc;
     54        errno_t rc;
    5555
    5656        argc = cli_count_args(argv);
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r36f0738 rb7fd2a0  
    195195static unsigned int rm_recursive(const char *path)
    196196{
    197         int rc;
     197        errno_t rc;
    198198        unsigned int ret = 0;
    199199
  • uspace/app/bdsh/cmds/modules/sleep/sleep.c

    r36f0738 rb7fd2a0  
    6262 * @return EOK if conversion was successful.
    6363 */
    64 static int decimal_to_useconds(const char *nptr, useconds_t *result)
     64static errno_t decimal_to_useconds(const char *nptr, useconds_t *result)
    6565{
    66         int ret;
     66        errno_t ret;
    6767        uint64_t whole_seconds;
    6868        uint64_t frac_seconds;
     
    112112int cmd_sleep(char **argv)
    113113{
    114         int ret;
     114        errno_t ret;
    115115        unsigned int argc;
    116116        useconds_t duration = 0;
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    r36f0738 rb7fd2a0  
    123123                if ((!no_create) ||
    124124                    ((no_create) && (vfs_stat_path(buff, &file_stat) == EOK))) {
    125                         int rc = vfs_lookup(buff, WALK_REGULAR | WALK_MAY_CREATE, &fd);
     125                        errno_t rc = vfs_lookup(buff, WALK_REGULAR | WALK_MAY_CREATE, &fd);
    126126                        if (rc != EOK) {
    127127                                fd = -1;
  • uspace/app/bdsh/cmds/modules/unmount/unmount.c

    r36f0738 rb7fd2a0  
    5757{
    5858        unsigned int argc;
    59         int rc;
     59        errno_t rc;
    6060
    6161        argc = cli_count_args(argv);
Note: See TracChangeset for help on using the changeset viewer.