Skip to content

stty: fix baud rate display on ppc64le(#11708)#11816

Open
CyberSarvesh wants to merge 3 commits intouutils:mainfrom
CyberSarvesh:main
Open

stty: fix baud rate display on ppc64le(#11708)#11816
CyberSarvesh wants to merge 3 commits intouutils:mainfrom
CyberSarvesh:main

Conversation

@CyberSarvesh
Copy link
Copy Markdown

PR Description

Fixes: #11708

Summary

On ppc64le, stty prints incorrect baud rates (e.g. 15 instead of 38400).
This happens because cfgetospeed returns enum values (e.g. B38400 → 15), but the current code only applies enum-to-string mapping for powerpc and powerpc64 big-endian.

As a result, ppc64le incorrectly falls into the direct-print path.

Root Cause

The existing cfg conditions assume that only big-endian PowerPC64 uses enum-based baud rates:

all(target_arch = "powerpc64", target_endian = "big")

However, on ppc64le (target_endian = "little"), cfgetospeed still returns enum values.

Fix

  • Remove endian-specific condition
  • Treat all powerpc64 targets the same
  • Route them through BAUD_RATES mapping

I’m happy to make further adjustments if there are any issues with the conditions or edge cases I may have missed do recommend better practices to follow in the repo.

Copilot AI review requested due to automatic review settings April 15, 2026 05:18
Copy link
Copy Markdown

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

Adjusts stty baud-rate formatting so PowerPC64 little-endian (ppc64le) prints human-readable baud rates (e.g., 38400) instead of the underlying enum discriminant (e.g., 15), aligning behavior with other PowerPC targets.

Changes:

  • Remove endian-specific cfg gating so all powerpc64 Linux targets use the BAUD_RATES enum→string mapping.
  • Update in-code comments describing when baud rate can be printed directly vs needs mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/uu/stty/src/stty.rs Outdated
Comment on lines 651 to 655
#[cfg(any(target_os = "linux", bsd))]
#[cfg(all(
not(target_arch = "powerpc"),
not(all(target_arch = "powerpc64", target_endian = "big"))
not(target_arch = "powerpc64")
))]
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The #[cfg(any(target_os = "linux", bsd))] direct-print branch now excludes all powerpc64 targets, but the enum-mapping branch is Linux-only and the fallback branch excludes BSD. This means on BSD powerpc64 builds the speed token will not be printed at all (regression vs printing the numeric u32 speed). Consider splitting the cfgs so BSD always uses the direct-print path, and only gate the PowerPC enum mapping on target_os = "linux".

Copilot uses AI. Check for mistakes.
Comment thread src/uu/stty/src/stty.rs Outdated
Comment on lines +658 to +663
// On PowerPC (including powerpc64 and ppc64le), baud rates are represented as enum values,
// so we need to map them to their corresponding numeric strings for display.
#[cfg(target_os = "linux")]
#[cfg(any(
target_arch = "powerpc",
all(target_arch = "powerpc64", target_endian = "big")
target_arch = "powerpc64"
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The comment says “On PowerPC (including powerpc64 and ppc64le)…” but this block is guarded by #[cfg(target_os = "linux")]. To avoid misleading readers into thinking this applies to BSD/macOS PowerPC targets, consider updating the wording to explicitly say “On Linux PowerPC…”.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/retry is no longer failing!
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!

@CyberSarvesh
Copy link
Copy Markdown
Author

It looks like the remaining failures are related to CI environment issues rather than this change.
The OpenBSD job appears to fail in bindgen/clang, and the Android job is failing due to cargo not being available.
Since these errors occur outside the stty changes in this PR, they may be unrelated, but I’m happy to investigate further if needed.

@BAMF0
Copy link
Copy Markdown
Contributor

BAMF0 commented Apr 15, 2026

Hey there! Do you have any logs showing that this builds on ppc64le (the CI does not)? I am interested since this reverts the fix for the bug I experienced when building on ppc64le (#11282).

@CyberSarvesh
Copy link
Copy Markdown
Author

Environment

I tested this on a ppc64le environment (via QEMU), and I’m seeing different behavior from what was described in #11282.

image

Attempting to build the original code (which prints speed directly) results in:

image image

With the changes in this PR, the code builds successfully and produces:

image

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.

stty: stty -F /dev/tty reports incorrect baud rate on PowerPC64 Little-endian

3 participants