Changeset 0feb39b in mainline for uspace/app/bdsh/cmds/modules/ls/ls.c


Ignore:
Timestamp:
2019-06-01T12:32:46Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4a764d1
Parents:
f4f4b95
Message:

Correcting return type for printer function

Instead of returning a bool indicating a string, the
printer function in the command returns now an errno_t

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    rf4f4b95 r0feb39b  
    6666/* Prototypes for the ls command, excluding entry points. */
    6767static unsigned int ls_start(ls_job_t *);
    68 static bool ls_print(struct dir_elem_t *);
    69 static bool ls_print_single_column(struct dir_elem_t *);
     68static errno_t ls_print(struct dir_elem_t *);
     69static errno_t ls_print_single_column(struct dir_elem_t *);
    7070static int ls_cmp_type_name(const void *, const void *);
    7171static int ls_cmp_name(const void *, const void *);
     
    9696 * @param de            Directory element.
    9797 */
    98 static bool ls_print(struct dir_elem_t *de)
     98static errno_t ls_print(struct dir_elem_t *de)
    9999{
    100100        int width = 13;
     
    110110
    111111                        char *rptr;
    112                         if (cap_format(&cap, &rptr) == EOK) {
     112                        errno_t rc = cap_format(&cap, &rptr);
     113                        if (rc == EOK) {
    113114                                char bytes[9], suffix[3];
    114115                                sscanf(rptr, "%s %s", bytes, suffix);
     
    117118                                printf("%-40s\t%*s %2s\n", de->name, width - 3, bytes, suffix);
    118119                        } else
    119                                 return false;
     120                                return rc;
    120121                }
    121122        } else if (de->s.is_directory)
     
    124125                printf("%-40s\n", de->name);
    125126
    126         return true;
    127 }
    128 
    129 static bool ls_print_single_column(struct dir_elem_t *de)
     127        return EOK;
     128}
     129
     130static errno_t ls_print_single_column(struct dir_elem_t *de)
    130131{
    131132        if (de->s.is_file) {
     
    135136        }
    136137
    137         return true;
     138        return EOK;
    138139}
    139140
     
    253254
    254255        for (i = 0; i < nbdirs; i++) {
    255                 if (!ls.printer(&tosort[i])) {
     256                if (ls.printer(&tosort[i]) != EOK) {
    256257                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
    257258                        goto out;
     
    470471        switch (scope) {
    471472        case LS_FILE:
    472                 if (!ls.printer(&de)) {
     473                if (ls.printer(&de) != EOK) {
    473474                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
    474475                        return CMD_FAILURE;
Note: See TracChangeset for help on using the changeset viewer.