Skip to content

Remove unreachable else branch in TTY stdin relay#40330

Open
benhillis wants to merge 1 commit intofeature/wsl-for-appsfrom
copilot/fix-l1-unreachable-else
Open

Remove unreachable else branch in TTY stdin relay#40330
benhillis wants to merge 1 commit intofeature/wsl-for-appsfrom
copilot/fix-l1-unreachable-else

Conversation

@benhillis
Copy link
Copy Markdown
Member

write() on success returns a value in [0, count]. The condition (bytesWritten <= pendingStdin.size()) is therefore always true, making the else branch dead code. Simplify to unconditional erase.

write() on success returns a value in [0, count]. The condition
(bytesWritten <= pendingStdin.size()) is therefore always true,
making the else branch dead code. Simplify to unconditional erase.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benhillis benhillis requested a review from a team as a code owner April 25, 2026 21:09
Copilot AI review requested due to automatic review settings April 25, 2026 21:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the Linux-side TTY stdin relay in WSLCInit.cpp by removing an unreachable else branch after a successful write() call, based on POSIX write() semantics (success returns 0..count).

Changes:

  • Remove dead-code branch that logged an “Unexpected write result” after a successful write().
  • Unconditionally erase the written prefix of pendingStdin on successful write().

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