Ignore:
Timestamp:
2017-05-30T06:16:25Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c726209
Parents:
719a208
Message:

qsort() compliant with C standard.

File:
1 edited

Legend:

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

    r719a208 rf2460a50  
    3939#include <vfs/vfs.h>
    4040#include <str.h>
    41 #include <sort.h>
    4241
    4342#include "ls.h"
     
    6261static unsigned int ls_start(ls_job_t *);
    6362static void ls_print(struct dir_elem_t *);
    64 static int ls_cmp(void *, void *, void *);
     63static int ls_cmp(const void *, const void *);
    6564static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
    6665static unsigned int ls_recursive(const char *, DIR *);
     
    104103 * @param a             Pointer to the structure of the first element.
    105104 * @param b             Pointer to the structure of the second element.
    106  * @param arg           Pointer for an other and optionnal argument.
    107105 *
    108106 * @return              -1 if a < b, 1 otherwise.
    109107 */
    110 static int ls_cmp(void *a, void *b, void *arg)
    111 {
    112         struct dir_elem_t *da = a;
    113         struct dir_elem_t *db = b;
     108static int ls_cmp(const void *a, const void *b)
     109{
     110        struct dir_elem_t const *da = a;
     111        struct dir_elem_t const *db = b;
    114112       
    115113        if ((da->s.is_directory && db->s.is_file) ||
     
    191189        }
    192190       
    193         if (ls.sort) {
    194                 if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t),
    195                     ls_cmp, NULL)) {
    196                         printf("Sorting error.\n");
    197                 }
    198         }
     191        if (ls.sort)
     192                qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
    199193       
    200194        for (i = 0; i < nbdirs; i++)
Note: See TracChangeset for help on using the changeset viewer.