Skip to content

Commit a9732ee

Browse files
committed
decode_aprs.c: Limit __compar_fn_t to Linux
POSIX does not define __compar_fn_t. Rather than using it, except on a list systems where it does not exist, invert the conditional so that it is used when it is known to exist, and on other systems -- including unknown systems -- use a POSIX-compatible invocation. Probably switching on __linux__ isn't really right, and instead there should be a feature test in cmake. Alternatively, since passing tocall_cmp without a cast doesn't result in warning, because it is the same type except static, it would be simpler to just drop the use of __compar_fn_t entirely.
1 parent 366e0ab commit a9732ee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/decode_aprs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3935,10 +3935,11 @@ static void decode_tocall (decode_aprs_t *A, char *dest)
39353935
* models before getting to the more generic APY.
39363936
*/
39373937

3938-
#if defined(__WIN32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
3939-
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), tocall_cmp);
3940-
#else
3938+
#if defined(__linux__)
3939+
/* glibc defines __compar_fn_t, which is not defined by POSIX. */
39413940
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), (__compar_fn_t)tocall_cmp);
3941+
#else
3942+
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), tocall_cmp);
39423943
#endif
39433944
}
39443945
else {

0 commit comments

Comments
 (0)