Changeset b7fd2a0 in mainline for uspace/lib/bithenge/src/print.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/print.c

    r36f0738 rb7fd2a0  
    7373}
    7474
    75 static int print_node(state_t *, bithenge_node_t *);
     75static errno_t print_node(state_t *, bithenge_node_t *);
    7676
    7777static void newline(state_t *state)
     
    9393}
    9494
    95 static int print_internal_func(bithenge_node_t *key, bithenge_node_t *value, void *data)
     95static errno_t print_internal_func(bithenge_node_t *key, bithenge_node_t *value, void *data)
    9696{
    9797        state_t *state = (state_t *)data;
    98         int rc = EOK;
     98        errno_t rc = EOK;
    9999        if (!state->first)
    100100                state_printf(state, ",");
     
    120120}
    121121
    122 static int print_internal(state_t *state, bithenge_node_t *node)
    123 {
    124         int rc;
     122static errno_t print_internal(state_t *state, bithenge_node_t *node)
     123{
     124        errno_t rc;
    125125        state_printf(state, "{");
    126126        increase_depth(state);
     
    137137}
    138138
    139 static int print_boolean(state_t *state, bithenge_node_t *node)
     139static errno_t print_boolean(state_t *state, bithenge_node_t *node)
    140140{
    141141        bool value = bithenge_boolean_node_value(node);
     
    151151}
    152152
    153 static int print_integer(state_t *state, bithenge_node_t *node)
     153static errno_t print_integer(state_t *state, bithenge_node_t *node)
    154154{
    155155        bithenge_int_t value = bithenge_integer_node_value(node);
     
    158158}
    159159
    160 static int print_string(state_t *state, bithenge_node_t *node)
     160static errno_t print_string(state_t *state, bithenge_node_t *node)
    161161{
    162162        const char *value = bithenge_string_node_value(node);
     
    164164        for (string_iterator_t i = string_iterator(value); !string_iterator_done(&i); ) {
    165165                wchar_t ch;
    166                 int rc = string_iterator_next(&i, &ch);
     166                errno_t rc = string_iterator_next(&i, &ch);
    167167                if (rc != EOK)
    168168                        return rc;
     
    179179}
    180180
    181 static int print_blob(state_t *state, bithenge_node_t *node)
     181static errno_t print_blob(state_t *state, bithenge_node_t *node)
    182182{
    183183        bithenge_blob_t *blob = bithenge_node_as_blob(node);
     
    185185        uint8_t buffer[1024];
    186186        aoff64_t size = sizeof(buffer);
    187         int rc;
     187        errno_t rc;
    188188        state_printf(state,
    189189            state->type == BITHENGE_PRINT_PYTHON ? "b\"" : "\"");
     
    201201}
    202202
    203 static int print_node(state_t *state, bithenge_node_t *tree)
     203static errno_t print_node(state_t *state, bithenge_node_t *tree)
    204204{
    205205        switch (bithenge_node_type(tree)) {
     
    222222 * @param tree The root node of the tree to print.
    223223 * @return EOK on success or an error code from errno.h. */
    224 int bithenge_print_node(bithenge_print_type_t type, bithenge_node_t *tree)
     224errno_t bithenge_print_node(bithenge_print_type_t type, bithenge_node_t *tree)
    225225{
    226226        state_t state = {type, true, 0, NULL, 0};
     
    236236 * @param tree The root node of the tree to print.
    237237 * @return EOK on success or an error code from errno.h. */
    238 int bithenge_print_node_to_string(char **str, size_t *size,
     238errno_t bithenge_print_node_to_string(char **str, size_t *size,
    239239    bithenge_print_type_t type, bithenge_node_t *tree)
    240240{
    241241        state_t state = {type, true, 0, *str, *size};
    242         int rc = print_node(&state, tree);
     242        errno_t rc = print_node(&state, tree);
    243243        *str = state.buffer;
    244244        *size = state.buffer_size;
Note: See TracChangeset for help on using the changeset viewer.