git: d19fe7ff24ed - main - audio/libfishsound: Fix build with Clang 16 and remove the workaround

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Mon, 21 Aug 2023 17:13:10 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d19fe7ff24ed397d90248e2588ee6c8518cf172d

commit d19fe7ff24ed397d90248e2588ee6c8518cf172d
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-08-21 17:02:46 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-08-21 17:02:46 +0000

    audio/libfishsound: Fix build with Clang 16 and remove the workaround
    
    flac.c:253:8: error: incompatible function pointer types passing 'FLAC__StreamDecoderReadStatus (const FLAC__StreamDecoder *, FLAC__byte *, unsigned int *, void *)' (aka 'FLAC__StreamDecoderReadStatus (const FLAC__StreamDecoder *, unsigned char *, unsigned int *, void *)') to parameter of type 'FLAC__StreamDecoderReadCallback' (aka 'FLAC__StreamDecoderReadStatus (*)(const FLAC__StreamDecoder *, unsigned char *, unsigned long *, void *)') [-Wincompatible-function-pointer-types]
           fs_flac_read_callback,
           ^~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/FLAC/stream_decoder.h:1092:34: note: passing argument to parameter 'read_callback' here
            FLAC__StreamDecoderReadCallback read_callback,
                                            ^
    flac.c:597:8: error: incompatible function pointer types passing 'FLAC__StreamEncoderWriteStatus (const FLAC__StreamEncoder *, const FLAC__byte *, unsigned int, unsigned int, unsigned int, void *)' (aka 'FLAC__StreamEncoderWriteStatus (const FLAC__StreamEncoder *, const unsigned char *, unsigned int, unsigned int, unsigned int, void *)') to parameter of type 'FLAC__StreamEncoderWriteCallback' (aka 'FLAC__StreamEncoderWriteStatus (*)(const FLAC__StreamEncoder *, const unsigned char *, unsigned long, unsigned int, unsigned int, void *)') [-Wincompatible-function-pointer-types]
           fs_flac_enc_write_callback,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/FLAC/stream_encoder.h:1532:136: note: passing argument to parameter 'write_callback' here
    FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
    
    16 warnings and 2 errors generated.
    
    Tested on:      14.0-CURRENT (1400093)
---
 audio/libfishsound/Makefile                        |  6 ------
 .../files/patch-src-libfishsound-flac.c            | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/audio/libfishsound/Makefile b/audio/libfishsound/Makefile
index 9ff7aaba0552..8f157fb7de3a 100644
--- a/audio/libfishsound/Makefile
+++ b/audio/libfishsound/Makefile
@@ -29,12 +29,6 @@ DOXYGEN_IMPLIES=DOCS
 
 DOXYGEN_BUILD_DEPENDS=	doxygen:devel/doxygen
 
-.include <bsd.port.options.mk>
-
-.if ${OPSYS} == FreeBSD && ( ${OSVERSION} >= 1400091 || ( ${OSVERSION} >= 1302507 && ${OSVERSION} < 1400000 ))
-CFLAGS+=	-Wno-error=incompatible-function-pointer-types
-.endif
-
 post-patch-DOCS-off:
 	@${REINPLACE_CMD} -e '/^SUBDIRS = / s| doc||' ${WRKSRC}/Makefile.in
 
diff --git a/audio/libfishsound/files/patch-src-libfishsound-flac.c b/audio/libfishsound/files/patch-src-libfishsound-flac.c
new file mode 100644
index 000000000000..dfea5e263cfa
--- /dev/null
+++ b/audio/libfishsound/files/patch-src-libfishsound-flac.c
@@ -0,0 +1,22 @@
+--- src/libfishsound/flac.c.orig	2010-02-03 13:34:02 UTC
++++ src/libfishsound/flac.c
+@@ -106,7 +106,7 @@ fs_flac_command (FishSound * fsound, int command, void
+ #if FS_DECODE
+ static FLAC__StreamDecoderReadStatus
+ fs_flac_read_callback(const FLAC__StreamDecoder *decoder,
+-                      FLAC__byte buffer[], unsigned int *bytes,
++                      FLAC__byte buffer[], size_t *bytes,
+                       void *client_data)
+ {
+   FishSound* fsound = (FishSound*)client_data;
+@@ -346,8 +346,8 @@ dec_err:
+ #if FS_ENCODE
+ static FLAC__StreamEncoderWriteStatus
+ fs_flac_enc_write_callback(const FLAC__StreamEncoder *encoder,
+-                           const FLAC__byte buffer[], unsigned bytes,
+-                           unsigned samples, unsigned current_frame,
++                           const FLAC__byte buffer[], size_t bytes,
++                           uint32_t samples, uint32_t current_frame,
+                            void *client_data)
+ {
+   FishSound* fsound = (FishSound*)client_data;