aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-09-03 04:04:22 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-23 04:24:59 -0400
commit6c1929894ca27ab2469c2c7bf25ad2625f567351 (patch)
tree02afe911b4dbf1efdffcbb8732f21a8797e8c947
parent3a5c9377f6d99ea23520f71340880b2fcb7bef11 (diff)
downloadgcc-6c1929894ca27ab2469c2c7bf25ad2625f567351.zip
gcc-6c1929894ca27ab2469c2c7bf25ad2625f567351.tar.gz
gcc-6c1929894ca27ab2469c2c7bf25ad2625f567351.tar.bz2
[Ada] Fix logic in C_Select under mingw
gcc/ada/ * libgnat/g-socthi__mingw.adb (C_Select): Fix logic in code and make it explicit that we are checking against null values before dereferencing them.
-rw-r--r--gcc/ada/libgnat/g-socthi__mingw.adb21
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/ada/libgnat/g-socthi__mingw.adb b/gcc/ada/libgnat/g-socthi__mingw.adb
index f63a6cb..dd8a68c 100644
--- a/gcc/ada/libgnat/g-socthi__mingw.adb
+++ b/gcc/ada/libgnat/g-socthi__mingw.adb
@@ -375,13 +375,10 @@ package body GNAT.Sockets.Thin is
Exceptfds : access Fd_Set;
Timeout : Timeval_Access) return C.int
is
- pragma Warnings (Off, Exceptfds);
-
- Original_WFS : aliased constant Fd_Set := Writefds.all;
-
- Res : C.int;
- S : aliased C.int;
- Last : aliased C.int;
+ Original_WFS : aliased Fd_Set;
+ Res : C.int;
+ S : aliased C.int;
+ Last : aliased C.int;
begin
-- Asynchronous connection failures are notified in the exception fd
@@ -392,7 +389,8 @@ package body GNAT.Sockets.Thin is
-- present in the initial write fd set, then move the socket from the
-- exception fd set to the write fd set.
- if Writefds /= No_Fd_Set_Access then
+ if Writefds /= null then
+ Original_WFS := Writefds.all;
-- Add any socket present in write fd set into exception fd set
@@ -411,7 +409,7 @@ package body GNAT.Sockets.Thin is
Res := Standard_Select (Nfds, Readfds, Writefds, Exceptfds, Timeout);
- if Exceptfds /= No_Fd_Set_Access then
+ if Exceptfds /= null then
declare
EFSC : aliased Fd_Set := Exceptfds.all;
Flag : constant C.int := SOSC.MSG_PEEK + SOSC.MSG_OOB;
@@ -448,8 +446,8 @@ package body GNAT.Sockets.Thin is
-- exception fd set back to write fd set. Otherwise, ignore
-- this event since the user is not watching for it.
- if Writefds /= No_Fd_Set_Access
- and then (Is_Socket_In_Set (Original_WFS'Access, S) /= 0)
+ if Writefds /= null
+ and then Is_Socket_In_Set (Original_WFS'Access, S) /= 0
then
Insert_Socket_In_Set (Writefds, S);
end if;
@@ -457,6 +455,7 @@ package body GNAT.Sockets.Thin is
end loop;
end;
end if;
+
return Res;
end C_Select;