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 MSVC compiler warnings #20022

Merged
merged 6 commits into from
Nov 23, 2023

Conversation

Jojo-Schmitz
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz commented Nov 14, 2023

  • reg.: unreferenced formal parameter (C4100)
  • reg.: conversion from 'size_t' to 'int', possible loss of data (C4267)

there's one warning left:

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C4702	unreachable code	braille	...\src\braille\internal\braillecode.cpp	1030	

which I don't understand, code in question:

braille_code* findBrailleCode(std::vector<braille_code*> code_lst, std::string code, bool partial_match)
{
if (partial_match) {
std::vector<std::string> codes = splitCodes(code);
for (braille_code* br : code_lst) {
std::vector<std::string> lst = splitCodes(br->code);
if (codes.size() > lst.size()) {
return nullptr;
}
for (size_t i=0; i < codes.size(); i++) {
if (codes[i] != lst[i]) {
return nullptr;
}
}
return br;
}
} else {

Possible fix:

  • reg.: unreachable code (C4702)
  • reg.: declaration hides function parameter (C4457)
  • Some 1000 warnings C4996, all in internal VS code, 'xutility', lines 1141, 1255 and 1256 and '__msvc_iter_core.hpp', lines 488-492, nothing we can fix, so disabled it.

And now also a compiler error:

  • reg.: undeclared identifier (C2065)

@Jojo-Schmitz Jojo-Schmitz force-pushed the compiler-warnings branch 7 times, most recently from 0bcd04f to dbf7963 Compare November 15, 2023 19:12
@cbjeukendrup
Copy link
Contributor

About that other warning: it's indeed a bit cryptical, but might relate to the fact that there's a return statement at the end of the body of the for loop, causing it to be executed at most once and thus making the loop unnecessary. It's indeed a slightly suspicious situation. @shoogle Could you please double-check that piece of code?

@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Nov 16, 2023

I see! And can guess what it really is ment to be, @shoogle, please check

@Jojo-Schmitz Jojo-Schmitz force-pushed the compiler-warnings branch 7 times, most recently from f147573 to 0bc0440 Compare November 17, 2023 21:40
@Jojo-Schmitz Jojo-Schmitz deleted the compiler-warnings branch November 18, 2023 11:56
@Jojo-Schmitz Jojo-Schmitz restored the compiler-warnings branch November 18, 2023 11:57
@Jojo-Schmitz Jojo-Schmitz reopened this Nov 18, 2023
@shoogle
Copy link
Contributor

shoogle commented Nov 18, 2023

@Jojo-Schmitz, the braille code was written by @TuanLa1972. The findBrailleCode() function doesn't appear to be used anywhere, but my guess is return br; was correct (i.e. your change is wrong) and the two return nullptr; lines above were supposed to be continue; instead.

@Jojo-Schmitz
Copy link
Contributor Author

Ah, I see, my guess wasn't just wrong, it was downright bad, thanks!
Amended to follow your sugggestion.
@TuanLa1972 please review.
If it is unused code though, we might as well just remove it?

@TuanLa1972
Copy link
Contributor

TuanLa1972 commented Nov 20, 2023 via email

@Jojo-Schmitz
Copy link
Contributor Author

OK, removed

@Jojo-Schmitz Jojo-Schmitz force-pushed the compiler-warnings branch 2 times, most recently from f51f7d7 to 18915e7 Compare November 21, 2023 11:26
Copy link
Contributor

@shoogle shoogle left a comment

Choose a reason for hiding this comment

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

I'm happy with the Braille find... functions being removed. They are not used anywhere.

The other changes seem reasonable as well.

@Jojo-Schmitz Jojo-Schmitz force-pushed the compiler-warnings branch 2 times, most recently from 172d3a6 to 6a477f4 Compare November 21, 2023 16:34
reg.: 'includeCrossStaffHeight': unreferenced formal parameter (C4100)
reg.: conversion from 'size_t' to 'int', possible loss of data (C4267)
reg. unreachable code (C4702)

Fixed by removing the offending and apparently unused code, along with another bunch of unused code.
reg.: declaration of 'item' hides function parameter (C4457)
reg.: 'includeCrossStaffHeight': undeclared identifier (C2065)
@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Nov 22, 2023

Now I also got and fixed a compiler error

Some 1000 warnings C4996, all in internal VS code,  'xutility', lines 1141, 1255 and 1256 and '__msvc_iter_core.hpp', lines 488-492
@igorkorsukov igorkorsukov merged commit eae12f9 into musescore:master Nov 23, 2023
11 checks passed
@Jojo-Schmitz Jojo-Schmitz deleted the compiler-warnings branch November 23, 2023 09:42
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.

5 participants