]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: use pointer decay for socket address type compatibility
authorAlexandre Oliva <oliva@adacore.com>
Thu, 17 Apr 2025 04:19:24 +0000 (01:19 -0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 30 Jun 2025 13:47:20 +0000 (15:47 +0200)
GCC 14 is stricter about type conversions.  Taking the address of an
array and decaying the array to a pointer to its first element yield
the same address, but the types are no longer considered compatible.
The socket data structures want decayed pointers rather than addresses
of arrays, so drop the '&'s.

gcc/ada/ChangeLog:

* socket.c [__vxworks]
(__gnat_gethostbyname): Drop excess '&'.
(__gnat_gethostbyaddr): Likewise.

gcc/ada/socket.c

index 77bdde40a24633d8d764a43f9eb7aeb5498bf7f3..a22ed993862be25cf5ff20b12571a210de792b8f 100644 (file)
@@ -280,10 +280,10 @@ __gnat_gethostbyname (const char *name,
     return -1;
   }
   ret->h_name      = name;
-  ret->h_aliases   = &vxw_h_aliases;
+  ret->h_aliases   = vxw_h_aliases;
   ret->h_addrtype  = AF_INET;
   ret->h_length    = 4;
-  ret->h_addr_list = &vxw_h_addr_list;
+  ret->h_addr_list = vxw_h_addr_list;
   return 0;
 }
 
@@ -302,18 +302,18 @@ __gnat_gethostbyaddr (const char *addr, int len, int type,
     return -1;
   }
 
-  if (hostGetByAddr (*(int*)addr, &vxw_h_name) != OK) {
+  if (hostGetByAddr (*(int*)addr, vxw_h_name) != OK) {
     *h_errnop = __gnat_get_h_errno ();
     return -1;
   }
 
   vxw_h_addr       = (long) addr;
 
-  ret->h_name      = &vxw_h_name;
-  ret->h_aliases   = &vxw_h_aliases;
+  ret->h_name      = vxw_h_name;
+  ret->h_aliases   = vxw_h_aliases;
   ret->h_addrtype  = AF_INET;
   ret->h_length    = 4;
-  ret->h_addr_list = &vxw_h_addr_list;
+  ret->h_addr_list = vxw_h_addr_list;
   return 0;
 }