Re: [Wireshark-dev] Build failure today

2018-04-20 Thread Guy Harris
On Apr 20, 2018, at 10:57 AM, Martin Mathieson via Wireshark-dev 
 wrote:

> I'm getting the error below:
> 
> Looking at the first one, my compiler doesn't seem to realise that 
> compute_offset()  will throw an exception rather than return a number without 
> setting *offset_ptr

That's because it *won't* throw an exception.  It'll return either "no error" 
or an exception for its caller to deal with.

What the compiler you're using doesn't realize is that nobody who calls 
compute_offset(), or calls something that calls compute_offset(), or 
{...(transitive closure of calls) compute_offset()} uses *offset_ptr if the 
return value is non-zero.  Not all compilers' data flow analysis appears to 
handle that.

> But when I look at e.g. BoundsError (which may be returned without setting 
> *offset_ptr), it is #defined as 1 in epan/exceptions.h
> 
> Surely the returns in compute_offset() should be THROW() calls instead?

No, because the routines's purpose is to check and, if the offset doesn't 
exist, return an exception to its caller.  Its caller might throw it or just 
pass it to its caller.  Some caller up the call chain, such as 
tvb_bytes_exist(), might just want to return a "these bytes are/aren't 
available in the captured data" indication rather than throwing an exception.

Dario Lombardo should have fixed that in 
1a9f3b8f6d65b50c0eaa78bde29ca50708900178.
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

[Wireshark-dev] Build failure today

2018-04-20 Thread Martin Mathieson via Wireshark-dev
I'm getting the error below:

Looking at the first one, my compiler doesn't seem to realise
that compute_offset()  will throw an exception rather than return a number
without setting *offset_ptr

But when I look at e.g. BoundsError (which may be returned without setting
*offset_ptr), it is #defined as 1 in epan/exceptions.h

Surely the returns in compute_offset() should be THROW() calls instead?

Martin


/home/martin/wireshark/epan/tvbuff.c: In function
‘tvb_captured_length_remaining’:
/home/martin/wireshark/epan/tvbuff.c:274:26: error: ‘abs_offset’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
   *rem_len = tvb->length - *offset_ptr;
  ^
/home/martin/wireshark/epan/tvbuff.c:499:8: note: ‘abs_offset’ was declared
here
  guint abs_offset, rem_length;
^
/home/martin/wireshark/epan/tvbuff.c: In function ‘tvb_bytes_exist’:
/home/martin/wireshark/epan/tvbuff.c:325:13: error: ‘abs_offset’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
  end_offset = *offset_ptr + *length_ptr;
 ^
/home/martin/wireshark/epan/tvbuff.c:550:8: note: ‘abs_offset’ was declared
here
  guint abs_offset, abs_length;
^
/home/martin/wireshark/epan/tvbuff.c: In function ‘tvb_offset_exists’:
/home/martin/wireshark/epan/tvbuff.c:675:5: error: ‘abs_offset’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  if (abs_offset < tvb->length) {
 ^
/home/martin/wireshark/epan/tvbuff.c: In function
‘tvb_reported_length_remaining’:
/home/martin/wireshark/epan/tvbuff.c:704:31: error: ‘abs_offset’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
   return tvb->reported_length - abs_offset;
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe