summaryrefslogtreecommitdiff
blob: 532b8fb45630434f7139543a4bd17f0954fefe3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
the qsort func expects a callback with const pointers, so update all the
prototypes to match

--- a/elist.c
+++ b/elist.c
@@ -136,7 +133,7 @@ elist_insert(elist_t *l, void *data)
   return(l);
 }
 
-void elist_sort(elist_t *l, int (sort_func)(void *, void *), int reverse)
+void elist_sort(elist_t *l, int (sort_func)(const void *, const void *), int reverse)
 {
   int c=0;
   elist_t *tl;
--- a/elist.h
+++ b/elist.h
@@ -33,7 +33,7 @@ extern void elist_free(elist_t *l, void (*data_free)(void *));
 extern elist_t * elist_append(elist_t *l, void *data);
 extern elist_t * elist_insert(elist_t *l, void *data);
 extern void
-elist_sort(elist_t *l, int (sort_func)(void *, void *), int reverse);
+elist_sort(elist_t *l, int (sort_func)(const void *, const void *), int reverse);
 #endif
 
 #endif
--- a/ls.c
+++ b/ls.c
@@ -98,15 +98,15 @@ long_disp(ls_file_t *info, int *col, int options);
 void
 short_disp(ls_file_t *info, int *col, int options);
 int
-no_sort(void *n1, void *n2);
+no_sort(const void *n1, const void *n2);
 int
-name_sort(void *n1, void *n2);
+name_sort(const void *n1, const void *n2);
 int
-inode_sort(void *n1, void *n2);
+inode_sort(const void *n1, const void *n2);
 int
-mod_time_sort(void *n1, void *n2);
+mod_time_sort(const void *n1, const void *n2);
 int
-creat_time_sort(void *n1, void *n2);
+creat_time_sort(const void *n1, const void *n2);
 long
 add_ls_file(char *name, int namelen, ext2_ino_t dir, ext2_ino_t ino,
             int entry, int type, struct list_dir_struct *ls);
@@ -331,7 +331,7 @@ do_list_dir(int argc, char *argv[])
   char *dup_path = NULL;
   char *dir_name;
   char *base_name;
-  int (*file_sort)(void *n1, void *n2) = name_sort;
+  int (*file_sort)(const void *n1, const void *n2) = name_sort;
   void (*file_disp)(ls_file_t *n, int *col, int options) = short_disp;
   elist_t *files=NULL;
   int col=0;
@@ -791,7 +791,7 @@ void short_disp(ls_file_t *info, int *col, int options)
  * MM/DD/YY      Name               Description
  *
  */
-int no_sort(void *n1, void *n2)
+int no_sort(const void *n1, const void *n2)
 {
   ls_file_t *f1 = *((ls_file_t **) n1);
   ls_file_t *f2 = *((ls_file_t **) n2);
@@ -835,7 +835,7 @@ int no_sort(void *n1, void *n2)
  * MM/DD/YY      Name               Description
  *
  */
-int name_sort(void *n1, void *n2)
+int name_sort(const void *n1, const void *n2)
 {
   ls_file_t *f1 = *((ls_file_t **) n1);
   ls_file_t *f2 = *((ls_file_t **) n2);
@@ -880,7 +880,7 @@ int name_sort(void *n1, void *n2)
  * MM/DD/YY      Name               Description
  *
  */
-int inode_sort(void *n1, void *n2)
+int inode_sort(const void *n1, const void *n2)
 {
   ls_file_t *f1 = *((ls_file_t **) n1);
   ls_file_t *f2 = *((ls_file_t **) n2);
@@ -925,7 +925,7 @@ int inode_sort(void *n1, void *n2)
  * MM/DD/YY      Name               Description
  *
  */
-int mod_time_sort(void *n1, void *n2)
+int mod_time_sort(const void *n1, const void *n2)
 {
   ls_file_t *f1 = *((ls_file_t **) n1);
   ls_file_t *f2 = *((ls_file_t **) n2);
@@ -971,7 +971,7 @@ int mod_time_sort(void *n1, void *n2)
  * MM/DD/YY      Name               Description
  *
  */
-int creat_time_sort(void *n1, void *n2)
+int creat_time_sort(const void *n1, const void *n2)
 {
   ls_file_t *f1 = *((ls_file_t **) n1);
   ls_file_t *f2 = *((ls_file_t **) n2);