[16/19] tftpd: Fix build with GCC 14

Message ID 20240819100608.991138-17-michael.tremer@ipfire.org
State Staged
Commit cef89b9436a1ece8f02c300030f43648f6b39b83
Headers
Series [01/19] expect: Fix build with GCC 14.2 |

Commit Message

Michael Tremer Aug. 19, 2024, 10:06 a.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/tftpd                  |  3 ++-
 src/patches/tftp-c99.patch | 50 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 src/patches/tftp-c99.patch
  

Patch

diff --git a/lfs/tftpd b/lfs/tftpd
index 8a3e7bd31..ebd8fee85 100644
--- a/lfs/tftpd
+++ b/lfs/tftpd
@@ -34,7 +34,7 @@  DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 PROG       = tftpd
-PAK_VER    = 4
+PAK_VER    = 5
 
 DEPS       =
 
@@ -83,6 +83,7 @@  $(subst %,%_BLAKE2,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/tftp-c99.patch
 	cd $(DIR_APP) && ./configure --prefix=/usr --without-tcpwrappers
 	cd $(DIR_APP) && make $(MAKETUNING)
 	cd $(DIR_APP) && make install
diff --git a/src/patches/tftp-c99.patch b/src/patches/tftp-c99.patch
new file mode 100644
index 000000000..40bb4ddd6
--- /dev/null
+++ b/src/patches/tftp-c99.patch
@@ -0,0 +1,50 @@ 
+The glibc headers do not declare bsd_signal by default.  Call signal
+instead, which is the same function as bsd_signal in current glibc.
+
+This fixes implicit function declarations and avoids build issues with
+future compilers.
+
+diff --git a/tftp/main.c b/tftp/main.c
+index fcf5a25ac654954b..7e399d414ca0dd2b 100644
+--- a/tftp/main.c
++++ b/tftp/main.c
+@@ -310,7 +310,7 @@ int main(int argc, char *argv[])
+         sp->s_proto = (char *)"udp";
+     }
+ 
+-    bsd_signal(SIGINT, intr);
++    signal(SIGINT, intr);
+ 
+     if (peerargc) {
+         /* Set peer */
+@@ -791,7 +791,7 @@ void intr(int sig)
+ {
+     (void)sig;                  /* Quiet unused warning */
+ 
+-    bsd_signal(SIGALRM, SIG_IGN);
++    signal(SIGALRM, SIG_IGN);
+     alarm(0);
+     siglongjmp(toplevel, -1);
+ }
+diff --git a/tftp/tftp.c b/tftp/tftp.c
+index 109848c4f9a5ad4e..d31553be5b76e305 100644
+--- a/tftp/tftp.c
++++ b/tftp/tftp.c
+@@ -85,7 +85,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode)
+     is_request = 1;             /* First packet is the actual WRQ */
+     amount = 0;
+ 
+-    bsd_signal(SIGALRM, timer);
++    signal(SIGALRM, timer);
+     do {
+         if (is_request) {
+             size = makerequest(WRQ, name, dp, mode) - 4;
+@@ -191,7 +191,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode)
+     firsttrip = 1;
+     amount = 0;
+ 
+-    bsd_signal(SIGALRM, timer);
++    signal(SIGALRM, timer);
+     do {
+         if (firsttrip) {
+             size = makerequest(RRQ, name, ap, mode);