Changeset b7fd2a0 in mainline for uspace/app/bdsh


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
Files:
23 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);
  • uspace/app/bdsh/compl.c

    r36f0738 rb7fd2a0  
    4040#include "tok.h"
    4141
    42 static int compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
    43 static int compl_get_next(void *state, char **compl);
     42static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
     43static errno_t compl_get_next(void *state, char **compl);
    4444static void compl_fini(void *state);
    4545
     
    8787 * Set up iterators in completion object, based on current token.
    8888 */
    89 static int compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state)
     89static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state)
    9090{
    9191        compl_t *cs = NULL;
     
    9393        char *prefix = NULL;
    9494        char *dirname = NULL;
    95         int retval;
     95        errno_t retval;
    9696       
    9797        token_t *tokens = calloc(WORD_MAX, sizeof(token_t));
     
    288288
    289289/** Get next match. */
    290 static int compl_get_next(void *state, char **compl)
     290static errno_t compl_get_next(void *state, char **compl)
    291291{
    292292        compl_t *cs = (compl_t *) state;
  • uspace/app/bdsh/exec.c

    r36f0738 rb7fd2a0  
    5858        int fd;
    5959
    60         int rc = vfs_lookup_open(f, WALK_REGULAR, MODE_READ, &fd);
     60        errno_t rc = vfs_lookup_open(f, WALK_REGULAR, MODE_READ, &fd);
    6161        if (rc == EOK) {
    6262                vfs_put(fd);
     
    9898        task_exit_t texit;
    9999        char *tmp;
    100         int rc;
     100        errno_t rc;
    101101        int retval, i;
    102102        int file_handles[3] = { -1, -1, -1 };
  • uspace/app/bdsh/input.c

    r36f0738 rb7fd2a0  
    6565 * invokes the built-in entry point (a[0]) passing all arguments in a[] to
    6666 * the handler */
    67 int process_input(cliuser_t *usr)
     67errno_t process_input(cliuser_t *usr)
    6868{
    6969        token_t *tokens_buf = calloc(WORD_MAX, sizeof(token_t));
     
    7373       
    7474        char *cmd[WORD_MAX];
    75         int rc = EOK;
     75        errno_t rc = EOK;
    7676        tokenizer_t tok;
    7777        unsigned int i, pipe_count, processed_pipes;
     
    259259{
    260260        char *str;
    261         int rc;
     261        errno_t rc;
    262262       
    263263        tinput_set_prompt(tinput, usr->prompt);
  • uspace/app/bdsh/input.h

    r36f0738 rb7fd2a0  
    3535
    3636extern void get_input(cliuser_t *);
    37 extern int process_input(cliuser_t *);
     37extern errno_t process_input(cliuser_t *);
    3838extern int input_init(void);
    3939
  • uspace/app/bdsh/scli.c

    r36f0738 rb7fd2a0  
    9898int main(int argc, char *argv[])
    9999{
    100         int ret = 0;
     100        errno_t ret = 0;
    101101       
    102102        stdiostate.stdin = stdin;
  • uspace/app/bdsh/scli.h

    r36f0738 rb7fd2a0  
    3939        char *cwd;
    4040        char *prompt;
    41         int lasterr;
     41        errno_t lasterr;
    4242} cliuser_t;
    4343
  • uspace/app/bdsh/test/toktest.c

    r36f0738 rb7fd2a0  
    4646        str_cpy(input_buffer, MAX_INPUT, input);
    4747
    48         int rc = tok_init(&tokenizer, input_buffer, tokens, MAX_TOKENS);
     48        errno_t rc = tok_init(&tokenizer, input_buffer, tokens, MAX_TOKENS);
    4949        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5050
  • uspace/app/bdsh/tok.c

    r36f0738 rb7fd2a0  
    3838static wchar_t tok_get_char(tokenizer_t *);
    3939static wchar_t tok_look_char(tokenizer_t *);
    40 static int tok_push_char(tokenizer_t *, wchar_t);
    41 static int tok_push_token(tokenizer_t *);
     40static errno_t tok_push_char(tokenizer_t *, wchar_t);
     41static errno_t tok_push_token(tokenizer_t *);
    4242static bool tok_pending_chars(tokenizer_t *);
    43 static int tok_finish_string(tokenizer_t *);
     43static errno_t tok_finish_string(tokenizer_t *);
    4444static void tok_start_token(tokenizer_t *, token_type_t);
    4545
     
    5151 * @param max_tokens number of elements of the out_tokens array
    5252 */
    53 int tok_init(tokenizer_t *tok, char *input, token_t *out_tokens,
     53errno_t tok_init(tokenizer_t *tok, char *input, token_t *out_tokens,
    5454    size_t max_tokens)
    5555{       
     
    8989
    9090/** Tokenize the input string into the tokens */
    91 int tok_tokenize(tokenizer_t *tok, size_t *tokens_length)
    92 {
    93         int rc;
     91errno_t tok_tokenize(tokenizer_t *tok, size_t *tokens_length)
     92{
     93        errno_t rc;
    9494        wchar_t next_char;
    9595       
     
    178178
    179179/** Finish tokenizing an opened string */
    180 int tok_finish_string(tokenizer_t *tok)
    181 {
    182         int rc;
     180errno_t tok_finish_string(tokenizer_t *tok)
     181{
     182        errno_t rc;
    183183        wchar_t next_char;
    184184       
     
    233233
    234234/** Append a char to the end of the current token */
    235 int tok_push_char(tokenizer_t *tok, wchar_t ch)
     235errno_t tok_push_char(tokenizer_t *tok, wchar_t ch)
    236236{
    237237        return chr_encode(ch, tok->outbuf, &tok->outbuf_offset, tok->outbuf_size);
     
    244244
    245245/** Push the current token to the output array */
    246 int tok_push_token(tokenizer_t *tok)
     246errno_t tok_push_token(tokenizer_t *tok)
    247247{
    248248        if (tok->outtok_offset >= tok->outtok_size) {
  • uspace/app/bdsh/tok.h

    r36f0738 rb7fd2a0  
    6363} tokenizer_t;
    6464
    65 extern int tok_init(tokenizer_t *, char *, token_t *, size_t);
     65extern errno_t tok_init(tokenizer_t *, char *, token_t *, size_t);
    6666extern void tok_fini(tokenizer_t *);
    67 extern int tok_tokenize(tokenizer_t *, size_t *);
     67extern errno_t tok_tokenize(tokenizer_t *, size_t *);
    6868
    6969#endif
Note: See TracChangeset for help on using the changeset viewer.