Commit 74e813ec authored by hugues.jerome's avatar hugues.jerome Committed by yoogx

* Change marshalling function for ports to use Unsigned_16,

          which are safer in that context



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-ada@490 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 47707082
...@@ -190,7 +190,7 @@ package body PolyORB_HI.Messages is ...@@ -190,7 +190,7 @@ package body PolyORB_HI.Messages is
begin begin
return Stream_Element_Count return Stream_Element_Count
(Swap_Bytes (Swap_Bytes
(Interfaces.Integer_16 (Internal_To_Length (B)))); (Interfaces.Unsigned_16 (Internal_To_Length (B))));
end To_Length; end To_Length;
--------------- ---------------
...@@ -200,7 +200,7 @@ package body PolyORB_HI.Messages is ...@@ -200,7 +200,7 @@ package body PolyORB_HI.Messages is
function To_Buffer (L : Stream_Element_Count) return Message_Size_Buffer is function To_Buffer (L : Stream_Element_Count) return Message_Size_Buffer is
begin begin
return Internal_To_Buffer return Internal_To_Buffer
(Wrapper (Swap_Bytes (Interfaces.Integer_16 (L)))); (Wrapper (Swap_Bytes (Interfaces.Unsigned_16 (L))));
end To_Buffer; end To_Buffer;
end PolyORB_HI.Messages; end PolyORB_HI.Messages;
...@@ -34,4 +34,4 @@ with PolyORB_HI.Marshallers_G; ...@@ -34,4 +34,4 @@ with PolyORB_HI.Marshallers_G;
with Interfaces; with Interfaces;
package PolyORB_HI.Port_Type_Marshallers is package PolyORB_HI.Port_Type_Marshallers is
new PolyORB_HI.Marshallers_G (Interfaces.Integer_16); new PolyORB_HI.Marshallers_G (Interfaces.Unsigned_16);
...@@ -59,8 +59,8 @@ package body PolyORB_HI.Utils is ...@@ -59,8 +59,8 @@ package body PolyORB_HI.Utils is
-- Swap_Bytes -- -- Swap_Bytes --
---------------- ----------------
function Swap_Bytes (B : Interfaces.Integer_16) function Swap_Bytes (B : Interfaces.Unsigned_16)
return Interfaces.Integer_16 return Interfaces.Unsigned_16
is is
use System; use System;
begin begin
...@@ -84,9 +84,9 @@ package body PolyORB_HI.Utils is ...@@ -84,9 +84,9 @@ package body PolyORB_HI.Utils is
-- Internal_Code -- -- Internal_Code --
------------------- -------------------
function Internal_Code (P : Port_Type) return Integer_16 is function Internal_Code (P : Port_Type) return Unsigned_16 is
function To_Internal_Code is new Ada.Unchecked_Conversion function To_Internal_Code is new Ada.Unchecked_Conversion
(Port_Type, Integer_16); (Port_Type, Unsigned_16);
begin begin
return Swap_Bytes (To_Internal_Code (P)); return Swap_Bytes (To_Internal_Code (P));
end Internal_Code; end Internal_Code;
...@@ -95,9 +95,9 @@ package body PolyORB_HI.Utils is ...@@ -95,9 +95,9 @@ package body PolyORB_HI.Utils is
-- Corresponding_Port -- -- Corresponding_Port --
------------------------ ------------------------
function Corresponding_Port (I : Integer_16) return Port_Type is function Corresponding_Port (I : Unsigned_16) return Port_Type is
function To_Corresponding_Port is new Ada.Unchecked_Conversion function To_Corresponding_Port is new Ada.Unchecked_Conversion
(Integer_16, Port_Type); (Unsigned_16, Port_Type);
begin begin
return To_Corresponding_Port (Swap_Bytes (I)); return To_Corresponding_Port (Swap_Bytes (I));
end Corresponding_Port; end Corresponding_Port;
......
...@@ -69,11 +69,11 @@ package PolyORB_HI.Utils is ...@@ -69,11 +69,11 @@ package PolyORB_HI.Utils is
function Corresponding_Node is new Ada.Unchecked_Conversion function Corresponding_Node is new Ada.Unchecked_Conversion
(Integer_8, Node_Type); (Integer_8, Node_Type);
function Internal_Code (P : Port_Type) return Integer_16; function Internal_Code (P : Port_Type) return Unsigned_16;
function Corresponding_Port (I : Integer_16) return Port_Type; function Corresponding_Port (I : Unsigned_16) return Port_Type;
function Swap_Bytes (B : Interfaces.Integer_16) function Swap_Bytes (B : Interfaces.Unsigned_16)
return Interfaces.Integer_16; return Interfaces.Unsigned_16;
-- Swap bytes iff the host is little endian. This function is -- Swap bytes iff the host is little endian. This function is
-- notionnally equivalent to htons(). -- notionnally equivalent to htons().
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment