1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

fsp: Don't cast the qsort comparison function pointer.

Cast the parameters of the function instead.  The C standard does not
guarantee that a function can be properly called via a pointer of a
different type.
This commit is contained in:
Kalle Olavi Niemitalo 2007-03-05 20:18:59 +02:00 committed by Kalle Olavi Niemitalo
parent c06d6ba5d0
commit c3a6ca3ef0

View File

@ -105,8 +105,9 @@ fsp_error(int error)
}
static int
compare(FSP_RDENTRY *a, FSP_RDENTRY *b)
compare(const void *av, const void *bv)
{
const FSP_RDENTRY *a = av, *b = bv;
int res = ((b->type == FSP_RDTYPE_DIR) - (a->type == FSP_RDTYPE_DIR));
if (res)
@ -163,8 +164,7 @@ sort_and_display_entries(FSP_DIR *dir, const unsigned char dircolor[])
memcpy(&table[size], &fentry, sizeof(fentry));
size++;
}
qsort(table, size, sizeof(*table),
(int (*)(const void *, const void *)) compare);
qsort(table, size, sizeof(*table), compare);
for (i = 0; i < size; i++) {
display_entry(&table[i], dircolor);