Changeset b7fd2a0 in mainline for uspace/app/sbi


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 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/sbi/src
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/bigint.c

    r36f0738 rb7fd2a0  
    186186 *                      to @a dval.
    187187 */
    188 int bigint_get_value_int(bigint_t *bigint, int *dval)
     188errno_t bigint_get_value_int(bigint_t *bigint, int *dval)
    189189{
    190190        bigint_t vval, diff;
  • uspace/app/sbi/src/bigint.h

    r36f0738 rb7fd2a0  
    3838void bigint_destroy(bigint_t *bigint);
    3939
    40 int bigint_get_value_int(bigint_t *bigint, int *dval);
     40errno_t bigint_get_value_int(bigint_t *bigint, int *dval);
    4141bool_t bigint_is_zero(bigint_t *bigint);
    4242bool_t bigint_is_negative(bigint_t *bigint);
  • uspace/app/sbi/src/builtin/bi_char.c

    r36f0738 rb7fd2a0  
    7373        char *str;
    7474        int char_val;
    75         int rc;
     75        errno_t rc;
    7676
    7777#ifdef DEBUG_RUN_TRACE
  • uspace/app/sbi/src/builtin/bi_console.c

    r36f0738 rb7fd2a0  
    107107        rdata_var_t *var;
    108108        int char_val;
    109         int rc;
     109        errno_t rc;
    110110
    111111#ifdef DEBUG_RUN_TRACE
  • uspace/app/sbi/src/builtin/bi_string.c

    r36f0738 rb7fd2a0  
    125125        int length;
    126126
    127         int rc;
     127        errno_t rc;
    128128
    129129        /* Extract self.Value */
  • uspace/app/sbi/src/input.c

    r36f0738 rb7fd2a0  
    4545#define INPUT_BUFFER_SIZE 256
    4646
    47 static int input_init_file(input_t *input, const char *fname);
     47static errno_t input_init_file(input_t *input, const char *fname);
    4848static void input_init_interactive(input_t *input);
    4949static void input_init_string(input_t *input, const char *str);
     
    5757 *                      ENOENT when opening file fails.
    5858 */
    59 int input_new_file(input_t **input, const char *fname)
     59errno_t input_new_file(input_t **input, const char *fname)
    6060{
    6161        *input = malloc(sizeof(input_t));
     
    7171 * @return              EOK on success, ENOMEM when allocation fails.
    7272 */
    73 int input_new_interactive(input_t **input)
     73errno_t input_new_interactive(input_t **input)
    7474{
    7575        *input = malloc(sizeof(input_t));
     
    8787 * @return              EOK on success, ENOMEM when allocation fails.
    8888 */
    89 int input_new_string(input_t **input, const char *str)
     89errno_t input_new_string(input_t **input, const char *str)
    9090{
    9191        *input = malloc(sizeof(input_t));
     
    104104 * @return              EOK on success, ENOENT when opening file fails.
    105105*/
    106 static int input_init_file(input_t *input, const char *fname)
     106static errno_t input_init_file(input_t *input, const char *fname)
    107107{
    108108        FILE *f;
     
    174174 * @return              EOK on success, EIO on failure.
    175175 */
    176 int input_get_line(input_t *input, char **line)
     176errno_t input_get_line(input_t *input, char **line)
    177177{
    178178        const char *prompt;
  • uspace/app/sbi/src/input.h

    r36f0738 rb7fd2a0  
    3232#include "mytypes.h"
    3333
    34 int input_new_file(input_t **input, const char *fname);
    35 int input_new_interactive(input_t **input);
    36 int input_new_string(input_t **input, const char *str);
     34errno_t input_new_file(input_t **input, const char *fname);
     35errno_t input_new_interactive(input_t **input);
     36errno_t input_new_string(input_t **input, const char *str);
    3737
    38 int input_get_line(input_t *input, char **line);
     38errno_t input_get_line(input_t *input, char **line);
    3939int input_get_line_no(input_t *input);
    4040
  • uspace/app/sbi/src/lex.c

    r36f0738 rb7fd2a0  
    257257void lex_init(lex_t *lex, struct input *input)
    258258{
    259         int rc;
     259        errno_t rc;
    260260
    261261        lex->input = input;
     
    717717{
    718718        char *bp;
    719         int rc;
     719        errno_t rc;
    720720
    721721        bp = lex->ibp;
  • uspace/app/sbi/src/main.c

    r36f0738 rb7fd2a0  
    6161        stype_t stype;
    6262        run_t run;
    63         int rc;
     63        errno_t rc;
    6464
    6565        /* Store executable file path under which we have been invoked. */
  • uspace/app/sbi/src/os/helenos.c

    r36f0738 rb7fd2a0  
    151151 *                      EIO on decoding error.
    152152 */
    153 int os_str_get_char(const char *str, int index, int *out_char)
     153errno_t os_str_get_char(const char *str, int index, int *out_char)
    154154{
    155155        size_t offset;
     
    210210 * @param ptr   Place to store pointer to new string.
    211211 */
    212 int os_input_line(const char *prompt, char **ptr)
     212errno_t os_input_line(const char *prompt, char **ptr)
    213213{
    214214        char *line;
    215         int rc;
     215        errno_t rc;
    216216
    217217        if (tinput == NULL) {
     
    247247 *              Command is present just one, not duplicated.
    248248 */
    249 int os_exec(char *const cmd[])
     249errno_t os_exec(char *const cmd[])
    250250{
    251251        task_id_t tid;
    252252        task_wait_t twait;
    253253        task_exit_t texit;
    254         int rc;
     254        errno_t rc;
    255255        int retval;
    256256
  • uspace/app/sbi/src/os/os.h

    r36f0738 rb7fd2a0  
    3535char *os_str_dup(const char *str);
    3636size_t os_str_length(const char *str);
    37 int os_str_get_char(const char *str, int index, int *out_char);
     37errno_t os_str_get_char(const char *str, int index, int *out_char);
    3838char *os_chr_to_astr(wchar_t chr);
    3939void os_input_disp_help(void);
    40 int os_input_line(const char *prompt, char **ptr);
    41 int os_exec(char * const cmd[]);
     40errno_t os_input_line(const char *prompt, char **ptr);
     41errno_t os_exec(char * const cmd[]);
    4242
    4343void os_store_ef_path(char *path);
  • uspace/app/sbi/src/os/posix.c

    r36f0738 rb7fd2a0  
    114114 * @return      Zero if equal, nonzero if not equal
    115115 */
    116 int os_str_cmp(const char *a, const char *b)
     116errno_t os_str_cmp(const char *a, const char *b)
    117117{
    118118        return strcmp(a, b);
     
    147147 *                      EIO on decoding error.
    148148 */
    149 int os_str_get_char(const char *str, int index, int *out_char)
     149errno_t os_str_get_char(const char *str, int index, int *out_char)
    150150{
    151151        size_t len;
     
    193193 * @param ptr   Place to store pointer to new string.
    194194 */
    195 int os_input_line(const char *prompt, char **ptr)
     195errno_t os_input_line(const char *prompt, char **ptr)
    196196{
    197197        printf("%s", prompt);
     
    214214 *              Command is present just one, not duplicated.
    215215 */
    216 int os_exec(char *const cmd[])
     216errno_t os_exec(char *const cmd[])
    217217{
    218218        pid_t pid;
  • uspace/app/sbi/src/program.c

    r36f0738 rb7fd2a0  
    5555 *                      EINVAL if file has syntax errors.
    5656 */
    57 int program_file_process(stree_program_t *program, const char *fname)
     57errno_t program_file_process(stree_program_t *program, const char *fname)
    5858{
    5959        input_t *input;
    6060        lex_t lex;
    6161        parse_t parse;
    62         int rc;
     62        errno_t rc;
    6363
    6464        rc = input_new_file(&input, fname);
     
    9191 *                      has syntax errors.
    9292 */
    93 int program_lib_process(stree_program_t *program)
     93errno_t program_lib_process(stree_program_t *program)
    9494{
    95         int rc;
     95        errno_t rc;
    9696        char *path, *fname;
    9797        char *tmp;
  • uspace/app/sbi/src/program.h

    r36f0738 rb7fd2a0  
    3232#include "mytypes.h"
    3333
    34 int program_file_process(stree_program_t *program, const char *fname);
    35 int program_lib_process(stree_program_t *program);
     34errno_t program_file_process(stree_program_t *program, const char *fname);
     35errno_t program_lib_process(stree_program_t *program);
    3636
    3737#endif
  • uspace/app/sbi/src/run_expr.c

    r36f0738 rb7fd2a0  
    14141414        int length;
    14151415        int i;
    1416         int rc;
     1416        errno_t rc;
    14171417        int iextent;
    14181418
     
    22872287        int elem_index;
    22882288        int arg_val;
    2289         int rc;
     2289        errno_t rc;
    22902290
    22912291        rdata_item_t *ritem;
     
    24762476        int elem_index;
    24772477        int arg_val;
    2478         int rc1, rc2;
     2478        errno_t rc1, rc2;
    24792479
    24802480        rdata_value_t *value;
  • uspace/app/sbi/src/stype.c

    r36f0738 rb7fd2a0  
    18901890 * @return              EOK if equal, EINVAL if not.
    18911891 */
    1892 int stype_targs_check_equal(stype_t *stype, tdata_item_t *a_ti,
     1892errno_t stype_targs_check_equal(stype_t *stype, tdata_item_t *a_ti,
    18931893    tdata_item_t *b_ti)
    18941894{
  • uspace/app/sbi/src/stype.h

    r36f0738 rb7fd2a0  
    5050tdata_item_t *stype_tobject_find_pred(stype_t *stype, tdata_item_t *src,
    5151    tdata_item_t *dest);
    52 int stype_targs_check_equal(stype_t *stype, tdata_item_t *a_ti,
     52errno_t stype_targs_check_equal(stype_t *stype, tdata_item_t *a_ti,
    5353    tdata_item_t *b_ti);
    5454
Note: See TracChangeset for help on using the changeset viewer.