From: Dmitriy Anisimkov Date: Mon, 1 Jul 2019 13:34:34 +0000 (+0000) Subject: [Ada] GNAT.Sockets: fix Get_Address when AF_INET6 is not defined X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c46e926fa592e2df23d260791cde72162bfc10c;p=gcc.git [Ada] GNAT.Sockets: fix Get_Address when AF_INET6 is not defined 2019-07-01 Dmitriy Anisimkov gcc/ada/ * libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6 is not defined. From-SVN: r272856 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 82e808bf9a5..1d353e86328 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-01 Dmitriy Anisimkov + + * libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6 + is not defined. + 2019-07-01 Ed Schonberg * exp_attr.adb (Expand_Attribute_Reference, case Invalid_Value): diff --git a/gcc/ada/libgnat/g-sothco.adb b/gcc/ada/libgnat/g-sothco.adb index df82d012259..eb15ac2e842 100644 --- a/gcc/ada/libgnat/g-sothco.adb +++ b/gcc/ada/libgnat/g-sothco.adb @@ -59,14 +59,15 @@ package body GNAT.Sockets.Thin_Common is ----------------- function Get_Address (Sin : Sockaddr) return Sock_Addr_Type is + use type C.unsigned_short; Family : constant C.unsigned_short := (if SOSC.Has_Sockaddr_Len = 0 then Sin.Sin_Family.Short_Family else C.unsigned_short (Sin.Sin_Family.Char_Family)); + AF_INET6_Defined : constant Boolean := SOSC.AF_INET6 > 0; Result : Sock_Addr_Type - (case Family is - when SOSC.AF_INET6 => Family_Inet6, - when SOSC.AF_INET => Family_Inet, - when others => Family_Unspec); + (if AF_INET6_Defined and then SOSC.AF_INET6 = Family then Family_Inet6 + elsif SOSC.AF_INET = Family then Family_Inet + else Family_Unspec); begin Result.Port := Port_Type (Network_To_Short (Sin.Sin_Port));