masneyb / gftp

gFTP is a free multithreaded file transfer client for *NIX based machines. 56 language translations available.
http://www.gftp.org
MIT License
116 stars 21 forks source link

GCC-14 compatibility #178

Open NHOrus opened 4 months ago

NHOrus commented 4 months ago

GCC-14, by default, drops support for features of C that were invalidated in C99 and C89. See Gentoo article on changes

gftp currently fails to compile with error equivalent to default GCC-14 enabled:

clang -DHAVE_CONFIG_H -I. -I..  -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DSHARE_DIR=\"/usr/share/gftp\" -DLOCALE_DIR=\"/usr/share/locale\"   -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wno-incompatible-pointer-types-discards-qualifiers -c -o socket-connect.o socket-connect.c

socket-connect.c:399:31: error: incompatible pointer types passing 'size_t *' (aka 'unsigned long *') to parameter of type 'socklen_t *' (aka 'unsigned int *')
      [-Werror,-Wincompatible-pointer-types]
  399 |   newfd = accept (*fd, saddr, &request->remote_addr_len);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/socket.h:388:68: note: passing argument to parameter here
  388 | int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
      |                                                                    ^
NHOrus commented 4 months ago

patch

--- a/lib/gftp.h        2024-04-26 09:08:32.404275437 +0000
+++ b/lib/gftp.h        2024-04-26 09:11:56.292057323 +0000
@@ -361,7 +361,7 @@
   int wakeup_main_thread[2]; /* FD that gets written to by the threads to wakeup the parent */

   void *remote_addr;
-  size_t remote_addr_len;
+  socklen_t remote_addr_len;
   int ai_family;
   int ai_socktype;
   unsigned int use_udp : 1; /* does this use UDP protocol? *