From c3a6ca3ef021ca28672df0da0c8fc1cd1b617a32 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 5 Mar 2007 20:18:59 +0200 Subject: [PATCH] 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. --- src/protocol/fsp/fsp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c index 294a75f9d..18abace85 100644 --- a/src/protocol/fsp/fsp.c +++ b/src/protocol/fsp/fsp.c @@ -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);