Hi Khanh,

ACK from me.

Best Regards,
Thien
________________________________
From: Khanh Q Nguyen <khanh.q.nguy...@dektech.com.au>
Sent: Monday, May 22, 2023 4:42 PM
To: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>; Thien Minh Huynh 
<thien.m.hu...@dektech.com.au>
Cc: opensaf-devel@lists.sourceforge.net <opensaf-devel@lists.sourceforge.net>; 
Khanh Q Nguyen <khanh.q.nguy...@dektech.com.au>
Subject: [PATCH 1/1] pyosaf: type conversion before converting a value to a 
ctypes value pointer [#3338]

Pyosaf ccb fails to convert a value to a ctypes value pointer if
the input value is a string.

This fix will convert the input value to int or float if
the input value type is a numeric type.
---
 python/pyosaf/utils/immom/ccb.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/python/pyosaf/utils/immom/ccb.py b/python/pyosaf/utils/immom/ccb.py
index a23f777d3..cb6ec2e00 100644
--- a/python/pyosaf/utils/immom/ccb.py
+++ b/python/pyosaf/utils/immom/ccb.py
@@ -43,21 +43,21 @@ def _value_to_ctype_ptr(value_type, value):
         c_void_p: ctype pointer which points to value
     """
     if value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT32T:
-        ctypeptr = cast(pointer(SaInt32T(value)), c_void_p)
+        ctypeptr = cast(pointer(SaInt32T(int(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT32T:
-        ctypeptr = cast(pointer(SaUint32T(value)), c_void_p)
+        ctypeptr = cast(pointer(SaUint32T(int(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT64T:
-        ctypeptr = cast(pointer(SaInt64T(value)), c_void_p)
+        ctypeptr = cast(pointer(SaInt64T(int(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT64T:
-        ctypeptr = cast(pointer(SaUint64T(value)), c_void_p)
+        ctypeptr = cast(pointer(SaUint64T(int(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SATIMET:
-        ctypeptr = cast(pointer(SaTimeT(value)), c_void_p)
+        ctypeptr = cast(pointer(SaTimeT(int(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SANAMET:
         ctypeptr = cast(pointer(SaNameT(value)), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAFLOATT:
-        ctypeptr = cast(pointer(SaFloatT(value)), c_void_p)
+        ctypeptr = cast(pointer(SaFloatT(float(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SADOUBLET:
-        ctypeptr = cast(pointer(SaDoubleT(value)), c_void_p)
+        ctypeptr = cast(pointer(SaDoubleT(float(value))), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SASTRINGT:
         ctypeptr = cast(pointer(SaStringT(value)), c_void_p)
     elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAANYT:
--
2.17.1


_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to