Wireshark-dev: Re: [Wireshark-dev] About Dead Store in clang Analysis
From: John Sullivan <jsethdev@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 24 Mar 2011 22:59:20 +0000
On Thursday, March 24, 2011, 8:57:42 PM, Chris Maynard wrote:
> Alexis La Goutte <alexis.lagoutte@...> writes:

>> What it the official solution to fix this ?
>> 1) Remove the code 
>> 2) Ignore this warning 
>> 3) Comment the code  add a 
>>  /*     offset += 1;  Remove Clang Dead increment */

> Or ... convert the dissector to a "new-style" dissector where the number of
> bytes it consumes is returned, and in that case the offset should be incremented
> but will need to be returned from any functions so proper offset (and thus the
> proper number of bytes consumed) can be maintained and eventually returned from
> the dissector.

In fact it sort of does, except that it returns the calculated number
of bytes from the tag header. It might be then useful to compare this
value calculated from the header, with the actual number of bytes
dissected. Rather than just assume they will end up the same and throw
one away. We could be over- or under- dissecting, or the end point
could be passing garbage, and figuring that out is a main use case!

(Aside: my attitude to dead stores is that eliminating them is a job
for the compiler. The programmer's job is not to micro-optimize things
that can be done better by machine, but to structure the code so as to
make the semantics as clear as possible. And I think that includes, as
already pointed out, leaving things in a clean state for when the next
field is added to the end of that tag.)

John
-- 
Dead stars still burn