Skip to content

Fir MSVC compiler warnings#33772

Open
Jojo-Schmitz wants to merge 2 commits into
musescore:mainfrom
Jojo-Schmitz:compiler-warnings
Open

Fir MSVC compiler warnings#33772
Jojo-Schmitz wants to merge 2 commits into
musescore:mainfrom
Jojo-Schmitz:compiler-warnings

Conversation

@Jojo-Schmitz

Copy link
Copy Markdown
Contributor
  • reg.: 'initializing': conversion from 'size_t' to 'int', possible loss of data (C4267)
  • reg.: potentially uninitialized local variable 'actualOrientation' used (C4701)

reg.: 'initializing': conversion from 'size_t' to 'int', possible loss of data (C4267)
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6dff627b-1d3e-4d6d-905d-b433696fe984

📥 Commits

Reviewing files that changed from the base of the PR and between a58d94f and a107271.

📒 Files selected for processing (1)
  • src/engraving/rendering/score/systemheaderlayout.cpp

📝 Walkthrough

Walkthrough

This PR changes totInstrumentCount in formattedSharedStaffLabel from int to size_t to match vector::size(), and adds a default case to the SharedLabelOrientation switch that asserts/logs and assigns actualOrientation = SharedLabelOrientation::VOICE to ensure it is always initialized.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only lists the two compiler warnings being addressed but lacks the required template structure, missing issue resolution reference, context, motivation, and CLA/testing verification checkboxes. Use the full PR template including a 'Resolves: #' reference, description of changes and motivation, and complete all required checklist items with proper verification.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fir MSVC compiler warnings' appears to be a typo ('Fir' instead of 'Fix') and is vague about which warnings are addressed, though it does relate to the main change of fixing MSVC compiler warnings. Correct the apparent typo ('Fir' to 'Fix') and optionally be more specific about the warnings being fixed, such as 'Fix MSVC compiler warnings C4267 and C4701'.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped musescore/muse_framework.git.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/engraving/rendering/score/systemheaderlayout.cpp (1)

1175-1177: ⚡ Quick win

Consider explicitly setting a valid fallback value in the default case.

The default case correctly prevents the uninitialized variable warning. However, setting actualOrientation = orientation when orientation contains an invalid enum value (possible via the PropertyValue::fromQVariant conversion shown in context snippet 3) propagates that invalid value downstream. While the current code at line 1180 safely handles this by treating invalid values as the VOICE case, explicitly setting a known-valid fallback would be more robust and self-documenting:

default: // should not happen, but don't leave actualOrientation uninitialized
    actualOrientation = SharedLabelOrientation::VOICE;
    break;

This makes the fallback behavior explicit and prevents potential issues if future code assumes actualOrientation always contains a valid enumerator.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/rendering/score/systemheaderlayout.cpp` around lines 1175 -
1177, The default branch in systemheaderlayout.cpp currently assigns
actualOrientation = orientation which can propagate an invalid enum value;
change the default case to assign a known-valid enumerator (e.g.
SharedLabelOrientation::VOICE) so actualOrientation always holds a valid
SharedLabelOrientation; update the switch/default that sets actualOrientation
(referencing actualOrientation, orientation, and the SharedLabelOrientation
enum) to use this explicit fallback and retain the break.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/engraving/rendering/score/systemheaderlayout.cpp`:
- Around line 1175-1177: The default branch in systemheaderlayout.cpp currently
assigns actualOrientation = orientation which can propagate an invalid enum
value; change the default case to assign a known-valid enumerator (e.g.
SharedLabelOrientation::VOICE) so actualOrientation always holds a valid
SharedLabelOrientation; update the switch/default that sets actualOrientation
(referencing actualOrientation, orientation, and the SharedLabelOrientation
enum) to use this explicit fallback and retain the break.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 90cba1bb-ce11-42e7-97a6-bff5eecaf30e

📥 Commits

Reviewing files that changed from the base of the PR and between 71dfef7 and a58d94f.

📒 Files selected for processing (1)
  • src/engraving/rendering/score/systemheaderlayout.cpp

reg.: potentially uninitialized local variable 'actualOrientation' used (C4701)
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.

2 participants