* [PATCH] ada: Make Stream a "not null" parameter of Get_Address
@ 2008-04-16 19:08 Samuel Tardieu
2008-04-17 10:52 ` Arnaud Charlet
0 siblings, 1 reply; 2+ messages in thread
From: Samuel Tardieu @ 2008-04-16 19:08 UTC (permalink / raw)
To: gcc-patches
If Stream is null when calling Get_Address, Socket_Error is raised
immediately. Make it a "not null" parameter instead, as this makes no
sense to call it with a null pointer.
gcc/ada/
* g-socket.ads, g-socket.adb (Get_Address): Make Stream a
"not null" parameter.
Compiled on i686-pc-linux-gnu. Ok for trunk?
---
gcc/ada/g-socket.adb | 8 ++++----
gcc/ada/g-socket.ads | 3 ++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index 61d529c..18abfa8 100644
--- a/gcc/ada/g-socket.adb
+++ b/gcc/ada/g-socket.adb
@@ -763,11 +763,11 @@ package body GNAT.Sockets is
-- Get_Address --
-----------------
- function Get_Address (Stream : Stream_Access) return Sock_Addr_Type is
+ function Get_Address (Stream : not null Stream_Access)
+ return Sock_Addr_Type
+ is
begin
- if Stream = null then
- raise Socket_Error;
- elsif Stream.all in Datagram_Socket_Stream_Type then
+ if Stream.all in Datagram_Socket_Stream_Type then
return Datagram_Socket_Stream_Type (Stream.all).From;
else
return Get_Peer_Name (Stream_Socket_Stream_Type (Stream.all).Socket);
diff --git a/gcc/ada/g-socket.ads b/gcc/ada/g-socket.ads
index 0ed1be0..7efbe2e 100644
--- a/gcc/ada/g-socket.ads
+++ b/gcc/ada/g-socket.ads
@@ -900,7 +900,8 @@ package GNAT.Sockets is
-- Create a stream associated with a datagram-based socket that is already
-- bound. Send_To is the socket address to which messages are being sent.
- function Get_Address (Stream : Stream_Access) return Sock_Addr_Type;
+ function Get_Address (Stream : not null Stream_Access)
+ return Sock_Addr_Type;
-- Return the socket address from which the last message was received
procedure Free is new Ada.Unchecked_Deallocation
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ada: Make Stream a "not null" parameter of Get_Address
2008-04-16 19:08 [PATCH] ada: Make Stream a "not null" parameter of Get_Address Samuel Tardieu
@ 2008-04-17 10:52 ` Arnaud Charlet
0 siblings, 0 replies; 2+ messages in thread
From: Arnaud Charlet @ 2008-04-17 10:52 UTC (permalink / raw)
To: Samuel Tardieu; +Cc: gcc-patches, Thomas Quinot
> gcc/ada/
> * g-socket.ads, g-socket.adb (Get_Address): Make Stream a
> "not null" parameter.
The formatting is not the preferred one, so OK in this form (review and
reformatting from Thomas):
--- g-socket.adb
+++ g-socket.adb
@@ -855,11 +855,11 @@ package body GNAT.Sockets is
-- Get_Address --
-----------------
- function Get_Address (Stream : Stream_Access) return Sock_Addr_Type is
+ function Get_Address
+ (Stream : not null Stream_Access) return Sock_Addr_Type
+ is
begin
- if Stream = null then
- raise Socket_Error;
- elsif Stream.all in Datagram_Socket_Stream_Type then
+ if Stream.all in Datagram_Socket_Stream_Type then
return Datagram_Socket_Stream_Type (Stream.all).From;
else
return Get_Peer_Name (Stream_Socket_Stream_Type (Stream.all).Socket);
--- g-socket.ads
+++ g-socket.ads
@@ -941,7 +941,8 @@ package GNAT.Sockets is
-- Create a stream associated with a datagram-based socket that is already
-- bound. Send_To is the socket address to which messages are being sent.
- function Get_Address (Stream : Stream_Access) return Sock_Addr_Type;
+ function Get_Address
+ (Stream : not null Stream_Access) return Sock_Addr_Type;
-- Return the socket address from which the last message was received
procedure Free is new Ada.Unchecked_Deallocation
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-17 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-16 19:08 [PATCH] ada: Make Stream a "not null" parameter of Get_Address Samuel Tardieu
2008-04-17 10:52 ` Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).