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

src/settingsimpl.cpp:108: suspicious for loop ? #146

Open
dcb314 opened this issue May 1, 2024 · 1 comment
Open

src/settingsimpl.cpp:108: suspicious for loop ? #146

dcb314 opened this issue May 1, 2024 · 1 comment

Comments

@dcb314
Copy link

dcb314 commented May 1, 2024

C compiler clang says:

src/settingsimpl.cpp:108:5: warning: variable 'it' is incremented both in the loop header and in the loop body [-Wfor-loop-analysis]

Source code is

FOREACH_SL(it, _uInfo) {
    comboBoxUserSrc->addItem(*it);
    ++it;
    if (!found && !(*it).isEmpty())
        found = true;
    if (!found)
        idx++;
    ++it;
}

Suggest code rework.

@tibirna
Copy link
Owner

tibirna commented May 2, 2024

Thank you for the investigation. The loop is correct. That code handles a bytestream list of 9 items, in 3 groups of 3, in which decision on the first element in the triad is taken based on information from the second. The code can't be easily made more readable. If you like you can add a #pragma GCC to disable the warning. Patches are greatly appreciated.

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

No branches or pull requests

2 participants