Page MenuHomeWildfire Games

Use prefix increment operator in a few places.
ClosedPublic

Authored by leper on May 4 2017, 1:12 AM.

Details

Reviewers
vladislavbelov
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP20113: Stop using postfix increment in a few places.
Summary

Pointed out by cppcheck.

Test Plan

-

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

leper created this revision.May 4 2017, 1:12 AM
vladislavbelov requested changes to this revision.EditedMay 4 2017, 1:15 AM
vladislavbelov added a subscriber: vladislavbelov.

Bump years, no?

This revision now requires changes to proceed.May 4 2017, 1:15 AM
elexis added a subscriber: elexis.May 4 2017, 1:16 AM

In the atlas directory there are 11 occurances of for*++) in loops, it doesn't comaplain about those?

In D414#17106, @elexis wrote:

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 ;-)

Bump years, no?

Hm, indeed. Guess I in that case I should also put 2017 there instead of the year those were actually done...

leper planned changes to this revision.May 4 2017, 1:51 AM
leper added a subscriber: trompetin17.
In D414#17106, @elexis wrote:

In the atlas directory there are 11 occurances of for*++) in loops, it doesn't comaplain about those?

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...

leper updated this revision to Diff 1633.May 4 2017, 2:47 AM
leper edited edge metadata.

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.

leper updated this revision to Diff 1634.May 4 2017, 2:48 AM

Missed something

The diff seems okay, and it compiles fine.

Vulcan added a subscriber: Vulcan.May 4 2017, 5:51 AM

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.

vladislavbelov added inline comments.May 4 2017, 11:27 AM
source/tools/atlas/GameInterface/ActorViewer.cpp
239 ↗(On Diff #1634)

May be early return?

source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
770 ↗(On Diff #1634)

Shouldn't continue be here?

leper added inline comments.May 4 2017, 11:32 AM
source/tools/atlas/GameInterface/ActorViewer.cpp
239 ↗(On Diff #1634)

Indeed.

source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
770 ↗(On Diff #1634)

It should be, but by now I'm wondering whether I should split this (I know why I didn't look at atlas code for quite a while...).

Vulcan added a comment.May 4 2017, 3:42 PM

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

Vulcan added a comment.May 4 2017, 5:17 PM

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.

leper added inline comments.May 19 2017, 8:14 PM
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...

vladislavbelov accepted this revision.May 20 2017, 7:11 PM

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.

This revision is now accepted and ready to land.May 20 2017, 7:11 PM
leper updated this revision to Diff 3464.Sep 2 2017, 2:03 AM

Stop using postfix increment (partially by using range based for loops).

Also remove the behaviour change (return to continue) present in the previous version.

Vulcan added a comment.Sep 2 2017, 3:03 AM

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.

Vulcan added a comment.Sep 2 2017, 3:04 AM
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.

This revision was automatically updated to reflect the committed changes.