git: ee691f844e79 - main - devel/libcbor: fix strict prototype warnings with clang 15

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 25 Dec 2022 17:54:40 UTC
The branch main has been updated by dim (src committer):

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

commit ee691f844e79c2092f5f9c06094c3a8bdab88c98
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-12-16 18:26:47 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-12-25 17:51:35 +0000

    devel/libcbor: fix strict prototype warnings with clang 15
    
    During an exp-run for llvm 15 (see bug 265425), it turned out that
    security/libfido2 failed to build with clang 15:
    
      In file included from /wrkdirs/usr/ports/security/libfido2/work/libfido2-1.12.0/src/aes256.c:8:
      In file included from /wrkdirs/usr/ports/security/libfido2/work/libfido2-1.12.0/src/fido.h:42:
      In file included from /usr/local/include/cbor.h:14:
      /usr/local/include/cbor/arrays.h:100:51: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
      CBOR_EXPORT cbor_item_t* cbor_new_indefinite_array();
                                                        ^
                                                         void
      In file included from /wrkdirs/usr/ports/security/libfido2/work/libfido2-1.12.0/src/aes256.c:8:
      In file included from /wrkdirs/usr/ports/security/libfido2/work/libfido2-1.12.0/src/fido.h:42:
      In file included from /usr/local/include/cbor.h:15:
      /usr/local/include/cbor/bytestrings.h:107:54: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
      CBOR_EXPORT cbor_item_t *cbor_new_definite_bytestring();
                                                           ^
                                                            void
    
    And many more of these -Werror warnings, all due to declarations in
    libcbor's headers. These are triggered because functions taking no
    parameters should be declared with "(void)", not "()".
    
    I would like to propose to fix the problem on the libcbor side, by
    editing the declarations and definitions of such functions in the port
    Makefile. This cleans up all warnings in devel/libcbor, and also fixes
    security/libfido2 as a consequence.
    
    PR:             268417
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2022Q4
---
 devel/libcbor/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/devel/libcbor/Makefile b/devel/libcbor/Makefile
index 6460e3a6c5ab..460fb2662868 100644
--- a/devel/libcbor/Makefile
+++ b/devel/libcbor/Makefile
@@ -24,5 +24,7 @@ USE_GITHUB=	yes
 
 post-patch:
 	@${REINPLACE_CMD} -e 's|-flto||; /subdirs(examples)/d' ${WRKSRC}/CMakeLists.txt
+	@${REINPLACE_CMD} -e 's|();|(void);|' ${WRKSRC}/src/cbor/*.h ${WRKSRC}/src/cbor/internal/*.h
+	@${REINPLACE_CMD} -e 's|() {|(void) {|' ${WRKSRC}/src/cbor/*.c ${WRKSRC}/src/cbor/internal/*.c
 
 .include <bsd.port.mk>