Pointed out by cppcheck.
Details
- Reviewers
vladislavbelov - Group Reviewers
Restricted Owners Package (Owns No Changed Paths) - Commits
- rP20113: Stop using postfix increment in a few places.
-
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
In the atlas directory there are 11 occurances of for*++) in loops, it doesn't comaplain about those?
I guess those are taken care of by D418, then again feel free to run cppcheck or point them out ;-)
Hm, indeed. Guess I in that case I should also put 2017 there instead of the year those were actually done...
Ah, after doing a grep, those are mostly integer types, and it doesn't warn about those (at least not at that one warning level).
That said looking at most of those occurences again, I guess I should just replace all of those by range-based for loops. Something that @trompetin17 did in the atlasui2 work already...
This should remove all postfix ++ occurences in loops in atlas.
Well all but those in one file that is ifdef-ed out and will be gone soon.
Build is green
Updating workspaces. Build (release)... Build (debug)... Running release tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
http://jw:8080/job/phabricator/985/ for more details.
Build has FAILED
Updating workspaces. Build (release)... ../../../source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp: In member function ‘virtual void AtlasMessage::cRotateObjectsFromCenterPoint::Do()’: ../../../source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp:824:8: error: ‘i’ was not declared in this scope if (i == 0) { ^ ../../../source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp: In member function ‘void AtlasMessage::cRotateObjectsFromCenterPoint::SetPos(const std::map<unsigned int, CVector3D>&, const std::map<unsigned int, float>&)’: ../../../source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp:866:65: error: passing ‘const std::map<unsigned int, float>’ as ‘this’ argument of ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = unsigned int; _Tp = float; _Compare = std::less<unsigned int>; _Alloc = std::allocator<std::pair<const unsigned int, float> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = float; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = unsigned int]’ discards qualifiers [-fpermissive] cmpPosition->SetYRotation(entity_angle_t::FromFloat(angle[id])); ^ make[1]: *** [obj/atlas_Release/ObjectHandlers.o] Error 1 make: *** [atlas] Error 2 make: *** Waiting for unfinished jobs....
Link to build: http://jw:8080/job/phabricator/994/
See console output for more information: http://jw:8080/job/phabricator/994/console
Build is green
Updating workspaces. Build (release)... Build (debug)... Running release tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
http://jw:8080/job/phabricator/995/ for more details.
source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp | ||
---|---|---|
862 ↗ | (On Diff #1634) | @vladislavbelov I guess we'd need a continue here too, but by now I'm relatively sure that these changes shouldn't be part of this diff. Care to submit a return/continue fix for both of these (and possibly more)? |
946 ↗ | (On Diff #1634) | And one more, maybe someone should check some commit/ticket/irc history and figure out if this wasn't just an oversight. |
965 ↗ | (On Diff #1634) | Well, I guess I did start with the behaviour change over here... |
I've tested it, it works for me. If early return/continue issues will be fixed in a separated commit, then this patch could be committed.
Stop using postfix increment (partially by using range based for loops).
Also remove the behaviour change (return to continue) present in the previous version.
Build is green
Updating workspaces. Build (release)... Build (debug)... Running release tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK! Checking XML files...
http://jenkins-master:8080/job/phabricator/1952/ for more details.
Executing section Default... Executing section Source... source/tools/atlas/GameInterface/ActorViewer.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: ''. source/tools/atlas/GameInterface/ActorViewer.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: 'MESSAGES_SKIP_STRUCTS'. source/tools/atlas/GameInterface/ActorViewer.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: '_MSC_VER'. source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: ''. source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: 'MESSAGES_SKIP_STRUCTS'. source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp | 33| #include·"graphics/Terrain.h" | | [MAJOR] CPPCheckBear (syntaxError): | | Invalid number of character ({) when these macros are defined: '_MSC_VER'. Executing section JS... Executing section XML GUI... Executing section Python... Executing section Perl...
http://jenkins-master:8080/job/phabricator_lint/469/ for more details.