libdxfrw icon indicating copy to clipboard operation
libdxfrw copied to clipboard

Opposite inner 'if' condition leads to a dead code block.

Open dismine opened this issue 3 years ago • 2 comments

Cppcheck warns that this code leads to a dead end.

https://github.com/LibreCAD/libdxfrw/blob/a610710c31f6029f70e169bd657d3a32e8e0bf38/src/drw_header.cpp#L604

Looks like because of this line

https://github.com/LibreCAD/libdxfrw/blob/a610710c31f6029f70e169bd657d3a32e8e0bf38/src/drw_header.cpp#L541

dismine avatar Aug 06 '22 13:08 dismine

Indeed, and there are some more https://github.com/LibreCAD/libdxfrw/blob/a610710c31f6029f70e169bd657d3a32e8e0bf38/src/drw_header.cpp#L1108-L1111 recognized by investigating LibreCAD/LibreCAD#636: https://github.com/LibreCAD/libdxfrw/blob/a610710c31f6029f70e169bd657d3a32e8e0bf38/src/drw_header.cpp#L1354-L1362 and possibly others.

Needs to check DXF version references, what is intended and if there are possible issues.

lordofbikes avatar Aug 06 '22 15:08 lordofbikes

After fixing LibreCAD/LibreCAD#636 I started to fix this one too, but it turned out to become a bottomless pit. I haven't checked commit history yet, to see if this happened with some code refactoring or if it is since beginning. Also have to check if there are any different DXF references, which led to this current status. From the spreadsheet I have, showing the various variables added and removed in DXF versions, I found several places where variables don't match with version conditions. And that not only applies to the mentioned condition.

lordofbikes avatar Sep 17 '22 13:09 lordofbikes