Skip to content

fix(windows): isolate Moonlight errno macros - #5805

Open
ArgaAAL wants to merge 4 commits into
LizardByte:masterfrom
ArgaAAL:fix/windows-moonlight-errno-isolation
Open

ArgaAAL wants to merge 4 commits into
LizardByte:masterfrom
ArgaAAL:fix/windows-moonlight-errno-isolation

Conversation

@ArgaAAL

@ArgaAAL ArgaAAL commented Sep 25, 2026

Copy link
Copy Markdown

Description

Moonlight’s headers could redefine some Windows errno values, which I found can then leak into Boost.

These changes will now save and restore those definitions around the two existing imports. Moonlight’s own C code stays unchanged. I added regression tests too, including the case where the wrapper is the first include.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Comment thread tests/unit/test_moonlight_common.cpp Outdated
}

// Capture errno immediately after including Moonlight.
#include <src/moonlight_common.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this sonar warning can't actually be corrected due to the way this test is supposed to work. You can use // NOSONAR(cpp:S954): <explain the reason here> comment

Comment thread src/compat/moonlight.h
@cgutman

cgutman commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

What stops us from just directly including the headers we care about rather than include all of Limelight-internal.h?

@ArgaAAL

ArgaAAL commented Oct 16, 2026

Copy link
Copy Markdown
Author

Sorry for the late follow-up. I moved both wrappers into src/compat/ and added the explanations for the two Sonar warnings.

I checked the individual Moonlight headers too. SS_ENC_* and ML_FF_SESSION_ID_V1 are still only in Limelight-internal.h, and these files use them. Kept the wrapper for now so we don’t duplicate those constants.

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The errno-isolation change fixes a leak that is still present on current master. Please integrate the new tests with the shared fixture and add the usual include-section comments as noted inline.

Validation: all five unchanged PR tests passed in an isolated MSYS2 UCRT64 harness with system Boost 1.91. Replacing the wrapper with the original direct import made the three errno-preservation tests fail. The suggested shared-test-header replacement also passed a syntax-only compile using the project's existing test flags. git diff --check and clang-format checks on the three new files passed. This was focused validation, not a full Sunshine build or test-suite run.

The current head a1284f83ca71888dc7b5673f593b2ab118022db2 is mergeable against master (5b2a4cfdfa643b5307906c68eb122e5a34855263). Verification limit for the maintainer: Actions workflows await approval, and the GH-Pages Read the Docs job timed out waiting for its missing Actions check. SonarCloud and the main documentation build passed.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Comment thread tests/unit/test_moonlight_common.cpp Outdated
Comment thread tests/unit/test_moonlight_common.cpp
@ArgaAAL

ArgaAAL commented Oct 17, 2026

Copy link
Copy Markdown
Author

Updated this to use the shared test header and added the include comments. Kept the include order needed for the errno checks.

Also ran the full Windows builds and tests on ARM64 and x64. Both passed, including the errno and audio tests, with the same skips and tray exclusions as before.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

3 participants