Skip to content

pmap: accept a 0x prefix in --range addresses - #819

Open
jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:pmap-range-hex-prefix
Open

jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:pmap-range-hex-prefix

Conversation

@jayhemnani9910

Copy link
Copy Markdown

-A/--range only takes bare hex digits, so an address with a 0x in front fails:

$ ./target/debug/procps pmap -A 0x0,0xffffffff 1000935
pmap: failed to parse argument: '0x0,0xffffffff'
$ pmap -A 0x0,0xffffffff 1000935    # procps-ng 4.0.4
1000935:   sleep 300
 total                0K

procps-ng takes the addresses with or without 0x (or 0X). A small parse_address now strips the prefix before from_str_radix. It's used for the single address and for both ends of a range. Whitespace and values over u64 stay errors, as the existing test wants.

Tests: test_range_arg gets 0xc00fee, 0Xc00fee, 0xc00,0xfee and ,0xffffffffffffffff as valid, and 0x, 0x, and 0x0xc00fee as invalid. The valid ones fail on main. cargo test: 224 passed, same as main, clippy and rustfmt clean. Against procps-ng 4.0.4's pmap on a running sleep, 16 -A forms (with and without the prefix, upper case, open ends, +, 0x alone, a doubled prefix, junk) give the same output now.

-A/--range only took bare hex digits, so "pmap -A 0x7f0000000000, PID"
failed with "failed to parse argument", while procps-ng pmap takes the
addresses with or without 0x (or 0X). Strip the prefix before parsing.
Copilot AI balanced review requested due to automatic review settings October 20, 2026 05:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.45%. Comparing base (67832aa) to head (2e673d2).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/pmap/src/pmap.rs 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #819      +/-   ##
==========================================
+ Coverage   19.20%   19.45%   +0.25%     
==========================================
  Files          68       68              
  Lines       10156    10238      +82     
  Branches      546      552       +6     
==========================================
+ Hits         1950     1992      +42     
- Misses       8206     8246      +40     
Flag Coverage Δ
macos_latest 6.74% <0.00%> (-0.01%) ⬇️
ubuntu_latest 19.81% <45.00%> (+0.25%) ⬆️
windows_latest 0.02% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/uu/pmap/src/pmap.rs Outdated

/// Parse an address for --range: hexadecimal, with or without a 0x prefix,
/// as procps-ng takes it.
fn parse_address(address: &str) -> Result<u64, std::num::ParseIntError> {

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.

since you are touching the three callers, could parse_address return the USimpleError directly?
the same map_err is there 3 times

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 2e673d2: parse_address takes the whole argument for the message and returns the USimpleError, so the three callers just use ?.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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