lua_map has a statement after a return which will never be executed

Bug #975852 reported by Hans Joachim Desserud on 2012-04-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Low
Unassigned

Bug Description

(Found by utils/create_cppcheck_report)

src/scripting/lua_map.cc:338 contains a statement after a return, which will then obviously never be executed. Since I don't know if the correct fix would be to remove it or place it in front of the return, I leave it to someone who knows what this code should do.

Tags: lua Edit Tag help
SirVer (sirver) wrote :

I just ran cppcheck 1.59 on this file and it did not report anything. Do I need to give it some flags? Assuming this is fixed/was a false positive and setting to invalid.

Changed in widelands:
status: Triaged → Invalid
milestone: build18-rc1 → none
Hans Joachim Desserud (hjd) wrote :

Try with --enable=all :)

$ cppcheck --enable=all src/scripting/lua_map.cc
Checking src/scripting/lua_map.cc...
[src/scripting/lua_map.cc:337]: (style) Statements following return, break, continue, goto or throw will never be executed.
snip...

PS. Completely unrelated, but I've seen that cppcheck report 1.59 report a lot more unused functions in this file among others. Should probably be investigated to rule out false postives, though since I don't know exactly how this works I thought I'd ask: will some of the lua-related functions be only called from lua-scripts and not the c++ code so that they would show up as dead code?

Changed in widelands:
status: Invalid → New
SirVer (sirver) wrote :

There is no return to be found around this place in the code - I wonder what it means. This is a false possible to be sure.

yes, the lua methods would all show up as dead code in analysis, but they are all exercised from the test suite.

Changed in widelands:
status: New → Invalid
SirVer (sirver) wrote :

I must be drunk - this error is fixed now.

Changed in widelands:
status: Invalid → Fix Committed
Hans Joachim Desserud (hjd) wrote :

>yes, the lua methods would all show up as dead code in analysis, but they are all exercised from the test suite.

I suspected something like that. There were a bit too many for it to sound like legitimate issues.

Thanks for fixing this error, btw.

Changed in widelands:
milestone: none → build18-rc1
SirVer (sirver) wrote :

Released in build-18 rc1.

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers