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

Misplaced initialization in output.cpp #4217

Open
JEAYNE opened this issue Feb 1, 2024 · 0 comments
Open

Misplaced initialization in output.cpp #4217

JEAYNE opened this issue Feb 1, 2024 · 0 comments
Labels
Engineering Anything to do with building/releasing/deploying uncrustify; with CI; or with the test framework.

Comments

@JEAYNE
Copy link
Contributor

JEAYNE commented Feb 1, 2024

Hi,

Look at how the variable first_text is used in the function output_text() in the file output.cpp

1063: for (size_t track = 0; track < pc->GetTrackingData()->size(); track++)
         ...
1069:    bool              first_text = true;
         ...
1081:       if (first_text)
1082:       {
               ...
1086:          first_text = false;
1087:       }
         ...
1095: }

This is a classic pattern, but, because first_text is set to false at the begining of each loop, the test if (first_text){ ... } is always true and the assignment first_text = false; is useless.

I think that first_text shoud be initialized before the loop.

Of course, the bug is only visible when the loop has to be executed more than once.

Regards

JEAYNE added a commit to JEAYNE/uncrustify.dev that referenced this issue Feb 3, 2024
@gmaurel gmaurel added the Engineering Anything to do with building/releasing/deploying uncrustify; with CI; or with the test framework. label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering Anything to do with building/releasing/deploying uncrustify; with CI; or with the test framework.
Projects
None yet
Development

No branches or pull requests

2 participants