commit:     be240aefac66f023742421eba6775a8f106a19ab
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 19:29:23 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 19:29:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=be240aef

net-analyzer/net-snmp: fix configure w/ clang 16

Closes: https://bugs.gentoo.org/879715
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/net-snmp-5.9.3-configure-clang16.patch   | 160 +++++++++++++++++++++
 ...-snmp-5.9.3.ebuild => net-snmp-5.9.3-r1.ebuild} |   1 +
 2 files changed, 161 insertions(+)

diff --git a/net-analyzer/net-snmp/files/net-snmp-5.9.3-configure-clang16.patch 
b/net-analyzer/net-snmp/files/net-snmp-5.9.3-configure-clang16.patch
new file mode 100644
index 000000000000..1eb880bb9604
--- /dev/null
+++ b/net-analyzer/net-snmp/files/net-snmp-5.9.3-configure-clang16.patch
@@ -0,0 +1,160 @@
+https://bugs.gentoo.org/879715
+https://github.com/net-snmp/net-snmp/commit/ddec5fa0ed1c76fde5eea9b974442faeec008526
+https://github.com/net-snmp/net-snmp/commit/fec0f9ee59d5d89c28d70bb35fad29a0013d048c
+https://github.com/net-snmp/net-snmp/commit/f362b354ce993d7394bf77db41bb27cfe8d1e307
+
+From ddec5fa0ed1c76fde5eea9b974442faeec008526 Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Thu, 17 Nov 2022 00:10:09 +0000
+Subject: [PATCH] configure.d: fix compatibility with Clang 16
+
+Clang 16 makes -Wimplicit-function-declaration and -Wimplicit-int an error by
+default. Unfortunately, this can lead to misconfiguration or miscompilation of
+software as configure tests may then return the wrong result.
+
+We also fix -Wstrict-prototypes while here as it's easy to do and it prepares
+us for C23.
+
+For more information, see LWN.net [0] or LLVM's Discourse [1], the Gentoo wiki
+[2], or the (new) c-std-porting mailing list [3].
+
+[0] https://lwn.net/Articles/913505/
+[1] 
https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
+[2] https://wiki.gentoo.org/wiki/Modern_C_porting
+[3] hosted at lists.linux.dev.
+
+Bug: https://bugs.gentoo.org/879715
+Signed-off-by: Sam James <s...@gentoo.org>
+[ bvanassche: removed two header file guards ]
+--- a/configure
++++ b/configure
+@@ -28483,7 +28483,14 @@ else
+ #ifdef HAVE_SYS_FS_TYPES_H
+ #include <sys/fs_types.h>
+ #endif
+-int main ()
++#ifdef HAVE_SYS_STATFS_H
++#include <sys/statfs.h>
++#endif
++#ifdef HAVE_SYS_STATVFS_H
++#include <sys/statvfs.h>
++#endif
++
++int main(void)
+ {
+ struct fs_data fsd;
+ /* Ultrix's statfs returns 1 for success,
+@@ -31851,8 +31858,10 @@ else
+ #if HAVE_SYS_SYSCTL_H
+ # include <sys/sysctl.h>
+ #endif
++#include <stddef.h>
++#include <stdlib.h>
+ 
+-int main(int argc, char **argv)
++int main(void)
+ {
+   int                 mib[2];
+   size_t              len;
+--- a/configure.d/config_os_functions
++++ b/configure.d/config_os_functions
+@@ -216,7 +216,14 @@ AC_CACHE_VAL(
+ #ifdef HAVE_SYS_FS_TYPES_H
+ #include <sys/fs_types.h>
+ #endif
+-int main ()
++#ifdef HAVE_SYS_STATFS_H
++#include <sys/statfs.h>
++#endif
++#ifdef HAVE_SYS_STATVFS_H
++#include <sys/statvfs.h>
++#endif
++
++int main(void)
+ {
+ struct fs_data fsd;
+ /* Ultrix's statfs returns 1 for success,
+--- a/configure.d/config_os_misc4
++++ b/configure.d/config_os_misc4
+@@ -185,8 +185,10 @@ else
+ #if HAVE_SYS_SYSCTL_H
+ # include <sys/sysctl.h>
+ #endif
++#include <stddef.h>
++#include <stdlib.h>
+ 
+-int main(int argc, char **argv)
++int main(void)
+ {
+   int                 mib[2];
+   size_t              len;
+
+From fec0f9ee59d5d89c28d70bb35fad29a0013d048c Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Thu, 17 Nov 2022 00:13:55 +0000
+Subject: [PATCH] agent/mibgroup: fix -Wstrict-prototypes
+
+Clang 16 warns on this. Fix it in preparation for C23.
+
+Signed-off-by: Sam James <s...@gentoo.org>
+[ bvanassche: minor formatting changes ]
+--- a/agent/mibgroup/agentx/protocol.c
++++ b/agent/mibgroup/agentx/protocol.c
+@@ -1895,7 +1895,7 @@ agentx_parse(netsnmp_session * session, netsnmp_pdu 
*pdu, u_char * data,
+ 
+ #ifdef TESTING
+ 
+-testit(netsnmp_pdu *pdu1)
++void testit(netsnmp_pdu *pdu1)
+ {
+     char            packet1[BUFSIZ];
+     char            packet2[BUFSIZ];
+@@ -1964,7 +1964,7 @@ testit(netsnmp_pdu *pdu1)
+ 
+ 
+ 
+-main()
++int main(void)
+ {
+     netsnmp_pdu     pdu1;
+     oid             oid_buf[] = { 1, 3, 6, 1, 2, 1, 10 };
+--- a/agent/mibgroup/header_complex.c
++++ b/agent/mibgroup/header_complex.c
+@@ -569,7 +569,7 @@ header_complex_dump(struct header_complex_index *thestuff)
+     }
+ }
+ 
+-main()
++int main(void)
+ {
+     oid             oidsave[MAX_OID_LEN];
+     int             len = MAX_OID_LEN, len2;
+
+From f362b354ce993d7394bf77db41bb27cfe8d1e307 Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Thu, 17 Nov 2022 00:20:04 +0000
+Subject: [PATCH] agent: fix -Wincompatible-function-pointer-types
+
+Clang 16 makes -Wincompatible-function-pointer-types an error by default.
+
+Fixes the following error:
+```
+mibgroup/if-mib/data_access/interface_linux.c:159:23: error: incompatible 
function pointer types assigning to 'void (*)(char *, ...) 
__attribute__((noreturn))' from 'void (char *, ...)' 
[-Wincompatible-function-pointer-types]
+    pci_access->error = netsnmp_pci_error;
+                      ^ ~~~~~~~~~~~~~~~~~
+1 error generated.
+```
+
+Signed-off-by: Sam James <s...@gentoo.org>
+--- a/agent/mibgroup/if-mib/data_access/interface_linux.c
++++ b/agent/mibgroup/if-mib/data_access/interface_linux.c
+@@ -31,7 +31,7 @@ static struct pci_access *pci_access;
+ /* Avoid letting libpci call exit(1) when no PCI bus is available. */
+ static int do_longjmp =0;
+ static jmp_buf err_buf;
+-static void
++PCI_NONRET static void
+ netsnmp_pci_error(char *msg, ...)
+ {
+     va_list args;
+

diff --git a/net-analyzer/net-snmp/net-snmp-5.9.3.ebuild 
b/net-analyzer/net-snmp/net-snmp-5.9.3-r1.ebuild
similarity index 99%
rename from net-analyzer/net-snmp/net-snmp-5.9.3.ebuild
rename to net-analyzer/net-snmp/net-snmp-5.9.3-r1.ebuild
index c5817c51719d..77d049d11aed 100644
--- a/net-analyzer/net-snmp/net-snmp-5.9.3.ebuild
+++ b/net-analyzer/net-snmp/net-snmp-5.9.3-r1.ebuild
@@ -91,6 +91,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-5.8.1-mysqlclient.patch
        "${FILESDIR}"/${PN}-5.9-MakeMaker.patch
        "${FILESDIR}"/${PN}-5.9.2-fix-LDFLAGS.patch
+       "${FILESDIR}"/${P}-configure-clang16.patch
        "${FILESDIR}"/${PN}-99999999-tinfo.patch
 )
 

Reply via email to