<font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">(Separated patches with signed-off-by
lines follow this email).</font>
<br>
<br><font size=2 face="sans-serif">My description of the issue with ssize_t
was lacking. In babeltrace.i.in we have the following declaration:</font>
<br>
<br><font size=2 face="sans-serif">        </font><tt><font size=2>ssize_t
bt_ctf_get_int_len(const struct bt_declaration *field);</font></tt>
<br>
<br><font size=2 face="sans-serif">Since ssize_t is not defined elsewhere
in babeltrace.i.in, SWIG (I am using swig-2.0.10) doesn't recognize it
as an integer, and generates the following code in babeltrace_wrap.c:4710</font>
<br>
<br><tt><font size=2>  result = bt_ctf_get_int_len((struct bt_declaration
const *)arg1);</font></tt>
<br><tt><font size=2>  resultobj = SWIG_NewPointerObj((ssize_t *)memcpy((ssize_t
*)malloc(sizeof(ssize_t)),&result,sizeof(ssize_t)), SWIGTYPE_p_ssize_t,
SWIG_POINTER_OWN |  0 );</font></tt>
<br><tt><font size=2>  return resultobj;</font></tt>
<br>
<br><font size=2 face="sans-serif">This is part of </font><tt><font size=2>_wrap__bt_ctf_get_int_len()</font></tt><font size=2 face="sans-serif">.</font>
<br>
<br><font size=2 face="sans-serif">When I compare this to a different function
that needs to return an integer, I see </font><tt><font size=2>_wrap__bt_ctf_get_array_len()</font></tt><font size=2 face="sans-serif">
for example, which has these lines:</font>
<br>
<br><tt><font size=2>  result = (int)bt_ctf_get_array_len((struct
bt_declaration const *)arg1);</font></tt>
<br><tt><font size=2>  resultobj = SWIG_From_int((int)(result));</font></tt>
<br><tt><font size=2>  return resultobj;</font></tt>
<br>
<br><font size=2 face="sans-serif">This is what led me to define ssize_t
as an unsigned long, which produced the correct result.</font>
<br>
<br><font size=2 face="sans-serif">Perhaps different versions of SWIG behave
differently, or perhaps still - the same version of SWIG when run on a
different system behaves differently.</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br>
<br><font size=2 color=#000080 face="sans-serif">Amit Margalit</font>
<br><font size=2 color=#808000 face="sans-serif">IBM XIV </font><font size=2 face="sans-serif">-
<i>Storage Reinvented</i></font>
<br><font size=2 face="sans-serif">XIV-NAS Development Team</font>
<br><font size=2 face="sans-serif">Tel. 03</font><font size=2 face="Arial">-689-7774</font>
<br><font size=2 face="Arial">Fax. 03-689-7230</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:      
 </font><font size=1 face="sans-serif">Jérémie Galarneau <jeremie.galarneau@efficios.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:      
 </font><font size=1 face="sans-serif">Amit Margalit/Israel/IBM@IBMIL</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:      
 </font><font size=1 face="sans-serif">"lttng-dev@lists.lttng.org"
<lttng-dev@lists.lttng.org></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:      
 </font><font size=1 face="sans-serif">08/19/2013 06:10 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:    
   </font><font size=1 face="sans-serif">Re: [lttng-dev]
[RFC patch] [Babeltrace python bindings] Added missing call to _bt_ctf_get_decl_from_def
in get_int_len(), and defined ssize_t</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by:    
   </font><font size=1 face="sans-serif">jeremie.galarneau@gmail.com</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3>Inlining for review.</font>
<br><font size=3>Please note that both patches in this series are missing
your "signed-off by" line.</font>
<br>
<br><font size=3>Also, the issues addressed in this patch are unrelated
and should be fixed separately.</font>
<br>
<br><font size=3>> From c3474a73eb137b2bb7984d3195094a263c024e65 Mon
Sep 17 00:00:00 2001</font>
<br><font size=3>> From: Amit Margalit <</font><a href=mailto:amitm@il.ibm.com><font size=3 color=blue><u>amitm@il.ibm.com</u></font></a><font size=3>></font>
<br><font size=3>> Date: Mon, 19 Aug 2013 14:08:40 +0300</font>
<br><font size=3>> Subject: [PATCH 1/2] Added missing call to _bt_ctf_get_decl_from_def
in</font>
<br><font size=3>>  get_int_len(), and defined ssize_t</font>
<br><font size=3>> </font>
<br><font size=3>> ---</font>
<br><font size=3>>  bindings/python/</font><a href=http://babeltrace.i.in/><font size=3 color=blue><u>babeltrace.i.in</u></font></a><font size=3>
| 3 ++-</font>
<br><font size=3>>  1 file changed, 2 insertions(+), 1 deletion(-)</font>
<br><font size=3>> </font>
<br><font size=3>> diff --git a/bindings/python/</font><a href=http://babeltrace.i.in/><font size=3 color=blue><u>babeltrace.i.in</u></font></a><font size=3>
b/bindings/python/</font><a href=http://babeltrace.i.in/><font size=3 color=blue><u>babeltrace.i.in</u></font></a>
<br><font size=3>> index dd2dacc..6c1f6fb 100644</font>
<br><font size=3>> --- a/bindings/python/</font><a href=http://babeltrace.i.in/><font size=3 color=blue><u>babeltrace.i.in</u></font></a>
<br><font size=3>> +++ b/bindings/python/</font><a href=http://babeltrace.i.in/><font size=3 color=blue><u>babeltrace.i.in</u></font></a>
<br><font size=3>> @@ -53,6 +53,7 @@ trace to it."</font>
<br><font size=3>>  typedef unsigned long long uint64_t;</font>
<br><font size=3>>  typedef long long int64_t;</font>
<br><font size=3>>  typedef int bt_intern_str;</font>
<br><font size=3>> +typedef unsigned long ssize_t;</font>
<br>
<br><font size=3>On which system is ssize_t undefined?</font>
<br><font size=3>I'd personally use ptrdiff_t, but maybe it is undefined
there too?</font>
<br>
<br><font size=3>These typedefs should be handled at config time, is it
something you would be interested in providing a patch for?</font>
<br>
<br><font size=3>>  </font>
<br><font size=3>>  /* =================================================================</font>
<br><font size=3>>   CONTEXT.H, CONTEXT-INTERNAL.H</font>
<br><font size=3>> @@ -866,7 +867,7 @@ class ctf:</font>
<br><font size=3>>   Return the size, in bits, of an int or a negative</font>
<br><font size=3>>   value on error.</font>
<br><font size=3>>   """</font>
<br><font size=3>> - return _bt_ctf_get_int_len(self._d)</font>
<br><font size=3>> + return _bt_ctf_get_int_len(_bt_ctf_get_decl_from_def(self._d))</font>
<br>
<br><font size=3>Good catch!</font>
<br>
<br><font size=3>>  </font>
<br><font size=3>>   def get_encoding(self):</font>
<br><font size=3>>   """</font>
<br><font size=3>> -- </font>
<br><font size=3>> 1.7.11.7</font>
<br><font size=3>> </font>
<br><font size=3><br>
</font>
<br><font size=3>On Mon, Aug 19, 2013 at 7:15 AM, Amit Margalit <</font><a href=mailto:AMITM@il.ibm.com target=_blank><font size=3 color=blue><u>AMITM@il.ibm.com</u></font></a><font size=3>>
wrote:</font>
<br><font size=3 face="sans-serif">In some systems, the system headers
use ssize_t, which was not defined, causing get_int_len() to return a pointer
to a python object instead of returning the integer.</font><font size=3>
</font><font size=3 face="sans-serif"><br>
Also, the python code that called _bt_ctf_get_int_len() failed to wrap
self._d with the call to _bt_ctf_get_decl_from_def.</font><font size=3>
<br>
</font><font size=3 face="sans-serif"><br>
I'm attaching this patch to (hopefully) avoid line formatting issues.</font><font size=3>
</font><font size=3 color=#8f8f8f><br>
<br>
<br>
<br>
</font><font size=3 color=#000080 face="sans-serif"><br>
Amit Margalit</font><font size=3 color=#8f8f8f> </font><font size=3 color=#808000 face="sans-serif"><br>
IBM XIV </font><font size=3 color=#8f8f8f face="sans-serif">- <i>Storage
Reinvented</i></font><font size=3 color=#8f8f8f> </font><font size=3 color=#8f8f8f face="sans-serif"><br>
XIV-NAS Development Team</font><font size=3 color=#8f8f8f> </font><font size=3 color=#8f8f8f face="sans-serif"><br>
Tel. 03</font><font size=3 color=#8f8f8f face="Arial">-689-7774</font><font size=3 color=#8f8f8f>
</font><font size=3 color=#8f8f8f face="Arial"><br>
Fax. 03-689-7230</font><font size=3><br>
_______________________________________________<br>
lttng-dev mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:lttng-dev@lists.lttng.org"><font size=3 color=blue><u>lttng-dev@lists.lttng.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target=_blank><font size=3 color=blue><u>http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</u></font></a><font size=3><br>
</font>
<br><font size=3><br>
</font>
<br>
<br><font size=3>-- <br>
Jérémie Galarneau<br>
EfficiOS Inc.</font><font size=3 color=blue><u><br>
</u></font><a href=http://www.efficios.com/ target=_blank><font size=3 color=blue><u>http://www.efficios.com</u></font></a><font size=3>
</font>
<br>