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 compiler warning Issue #21 #22

Merged
merged 1 commit into from
Jul 3, 2020
Merged

Conversation

g0uus
Copy link

@g0uus g0uus commented Oct 30, 2018

Removed last remaining warning in DMSSerial2 itself.

@@ -788,7 +788,7 @@ void DMXSerialClass2::_processRDMMessage(byte CmdClass, uint16_t Parameter, bool
WRITEINT(_rdm.packet.Data+ 6, E120_SENSOR_DEFINITION);
WRITEINT(_rdm.packet.Data+ 8, E120_SENSOR_VALUE);
}
for (int n = 0; n < _initData->additionalCommandsLength; n++) {
for (uint16_t n = 0; n < _initData->additionalCommandsLength; ++n) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how @mathertel feels, but given the rest of the codebase uses n++, I'd say it would be good to be consistent (or change the remainder of the codebase, but in which case it should probably be in another commit.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Peter,
Sorry, as a full time C++ developer, it is automatic for me to use the pre-increment operator rather than post-increment in for loops.
For a scalar like n there is absolutely no difference, however for non-scalars, a post-increment is more expensive than pre-increment because you have to copy the whole of the object to return the "before" value.

I have just looked through the codebase and I cant see any non-scalar use of post-increment so if you prefer, I can change it back to post increment - probably tomorrow as I am supposed to be working!

Copy link
Author

Choose a reason for hiding this comment

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

Pre/Post increment fixed in commit 396551f

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @g0uus . The same issue had obviously come up either here or elsewhere before, as I'd had the efficiency thing in my Google history.

If it's better practise, it might be worth updating it throughout, but like I say that's down to @mathertel really; my main interest was just in it being consistent throughout to make it easier for novices to understand.

Copy link
Owner

Choose a reason for hiding this comment

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

I have learned C by this book: http://www.lysator.liu.se/c/bwk-tutor.html#for. The use post-increment. I agree there is no difference so there should not be a change on this.
Switching the type is correct to avoid the warning.

Thanks for the contribution.

@mathertel mathertel merged commit 678d00d into mathertel:master Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants