Wireshark-dev: [Wireshark-dev] why does dissector_try_uint_new() return gboolean?
From: Martin Kaiser <lists@xxxxxxxxx>
Date: Tue, 24 Jul 2012 14:02:38 +0200
Dear all,

I have a tvbuff that contains one or more dvb sections. I don't know the
number of sections or their lengths (only the overall length but that
doesn't really matter).

Each table starts with a tag, I can get the dissector table for dvb/mpeg
sections and call dissector_try_uint_new(...) to dissect the first
section based on its leading tag byte.

Unfortunately, dissector_try_uint_new() returns true or false, not the
number of dissected bytes. Therefore, I can't find the start of the 2nd
and any following sections.

This is surprising since dissector_try_uint_new() knows the number of
dissected bytes. The few places where it's used now are converting the
gboolean return value back to an integer

  gboolean ret; 
  ret = dissector_try_uint_new(...);
  return ret ? tvb_length(tvb) : 0; 


Would it make sense to change dissector_try_uint_new() to return guint?
Should I leave dissector_try_uint_new() as it is and introduce a similar
function returning guint?

Or am I misunderstanding something? I suppose it is ok for a new-style
dissector to return something other than 0 or the complete tvb length.

Thanks,

   Martin