aap/librw

Recap: a lot of code is dead in assert() statements

Closed this issue · 1 comments

Examples:
https://github.com/aap/librw/blob/master/src/image.cpp#L65
https://github.com/aap/librw/blob/master/src/image.cpp#L179
https://github.com/aap/librw/blob/master/src/image.cpp#L241
https://github.com/aap/librw/blob/master/src/geometry.cpp#L106

  • it never finds the chunk if asserts are disabled

https://github.com/aap/librw/blob/master/src/image.cpp#L528

  • it never opens the file for writing TGA if asserts are disabled

In Release mode, some compilers like to put the preprocessor definition "NDEBUG" to disable things like the "assert" macro to speed up code. In return, your code breaks because assert statements do not execute in Release mode anymore. Please take a look at this issue. :)

I've fixed these links for you. I believe all of those have been fixed

assert(findChunk(stream, ID_STRUCT, NULL, NULL));

assert(findChunk(stream, ID_STRUCT, NULL, NULL));

assert(findChunk(stream, ID_STRUCT, NULL, NULL));

assert(findChunk(stream, ID_STRUCT, NULL, &version));

(the one in writeTGA has been moved to tga.cpp since)

assert(file.open(filename, "wb"));


@aap this can be closed