[Olsr-dev] First batch of Coverity fixes

Henning Rogge (spam-protected)
Mon Jul 15 09:25:28 CEST 2013


On 07/12/2013 03:49 PM, Bernd Petrovitsch wrote:
> Hi!
>
>> -  assert(ci_index < COOKIE_ID_MAX);     /* increase COOKIE_ID_MAX */
>> +  if (ci_index == COOKIE_ID_MAX) {
>> +    assert(false);     /* increase COOKIE_ID_MAX */
>
> The output given by this "assert()" is probably more misleading than the
> one from the original
> 	assert(ci_index < COOKIE_ID_MAX);
> .
>> +
>> +    /* assert will not be there when compiled without debug information */
>
> Yup, that is forgotten often. One needs a "stronger" assert() for that -
> something like
>
> #define ASSERT_EXIT(cond) do { assert(cond); if (!(cond)) exit(1); } while(0)
>
> Side-effects on "cond" are evil anyways as it may be compiled out
> completely ....
>
>> +    exit(1);
>> +  }

I thought a little bit more about the whole mess and the more time I 
spent on it the less I liked the my original patch. The whole 
"cookie_id" thing is insane anyways, it has no use beyond complicating 
access to the cookies and "branding" memcookies.

But branding has never been useful since GDB and Valgrind were available 
on our systems, I cannot remember a single case in the last 6 years 
where someone said "hey, the branding was killed, we have a problem".

So I wrote up a new patch, one that just kills the whole cookie_id and 
branding and put them into a linked list.

I tested this patch in a couple of VMs and it seems to be okay, but take 
a look at it.

Henning Rogge

-- 
Diplom-Informatiker Henning Rogge , Fraunhofer-Institut für
Kommunikation, Informationsverarbeitung und Ergonomie FKIE
Kommunikationssysteme (KOM)
Fraunhofer Straße 20, 53343 Wachtberg, Germany
Telefon +49 228 9435-961,   Fax +49 228 9435 685
mailto:(spam-protected) http://www.fkie.fraunhofer.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cookies.patch
Type: text/x-patch
Size: 8893 bytes
Desc: not available
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20130715/41371d02/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6169 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20130715/41371d02/attachment-0001.bin>


More information about the Olsr-dev mailing list