Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #822, Remove iterator modification in loop #826

Merged

Conversation

skliper
Copy link
Contributor

@skliper skliper commented Aug 21, 2020

Describe the contribution
Fix #822 - removed iterator modification from within the loop... replaced with break.

Testing performed
Built and ran unit tests.

Expected behavior changes
None

System(s) tested on

  • Hardware: cFS Dev Server
  • OS: Ubuntu 18.04
  • Versions: bundle (and cfe/osal main) + this change

Additional context
None

Third party code
None

Contributor Info - All information REQUIRED for consideration of pull request
Jacob Hageman - NASA/GSFC

@skliper skliper added enhancement CCB:Ready Ready for discussion at the Configuration Control Board (CCB) CCB:FastTrack labels Aug 21, 2020
Copy link
Contributor

@CDKnightNASA CDKnightNASA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was some discouragement from using breaks/continues in loops (akin to using returns in the middle of code.) I think breaks/continues/returns are fine and here's a good example of the contrary problem when they're avoided.

@skliper
Copy link
Contributor Author

skliper commented Aug 24, 2020

I see no mention of avoiding break/continue in Goddard's c coding standard. Alternatively could implement multiple conditions to end the for loop, but I've heard reviewers not like that approach either.

@astrogeco
Copy link
Contributor

Would it make sense to use a while loop?

@skliper
Copy link
Contributor Author

skliper commented Aug 24, 2020

I'm not aware of a coding standard that prefers one way over the other. Without a preference/standard stated, I don't think it's worth changing code. Either way there's an iterator and two exit conditions, for loop with a break seems fine to me.

@astrogeco
Copy link
Contributor

CCB 2020-08-26 - APPROVED

@yammajamma yammajamma added CCB-20200826 CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Aug 26, 2020
@yammajamma yammajamma changed the base branch from main to integration-candidate August 26, 2020 18:36
@yammajamma yammajamma merged commit 474b1a6 into nasa:integration-candidate Aug 26, 2020
@skliper skliper deleted the fix822-iterator-mod-in-loop branch February 1, 2021 22:05
@skliper skliper added this to the 7.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB CCB:FastTrack enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loop counters should not be modified in the body of the loop.
4 participants