Skip to content

Commit

Permalink
libmpathutil: avoid -Wcast-function-type-mismatch error with clang 19
Browse files Browse the repository at this point in the history
Avoid the following error with clang 19:

msort.c:268:27: error: cast from '__compar_fn_t' (aka 'int (*)(const void *, const void *)') to '__compar_d_fn_t' (aka 'int (*)(const void *, const void *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
  268 |         return msort_r (b, n, s, (__compar_d_fn_t)cmp, NULL);
      |                                  ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Martin Wilck <[email protected]>
  • Loading branch information
mwilck committed Nov 6, 2024
1 parent 7dc7b90 commit 9a58639
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libmpathutil/msort.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,12 @@ msort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
* If this is safe for them, it should be for us, too.
*/
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#if __GNUC__ >= 8 || __clang_major__ >= 19
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
#if __clang_major__ >= 19
#pragma GCC diagnostic ignored "-Wcast-function-type-mismatch"
#endif
void
msort (void *b, size_t n, size_t s, __compar_fn_t cmp)
{
Expand Down

0 comments on commit 9a58639

Please sign in to comment.