Skip to content

Commit c870ed1

Browse files
committed
refactor: simplify tty_nr decoding for major device 4
Remove unnecessary condition check in the match arm for virtual console terminals. Both branches returned the same value, so the condition was redundant. Addresses review feedback from PR uutils#533.
1 parent 2bbf963 commit c870ed1

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/uu/pgrep/src/process.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,7 @@ impl TryFrom<u64> for Teletype {
116116

117117
match major {
118118
// Virtual console terminals (/dev/tty1, /dev/tty2, etc.)
119-
4 => {
120-
if minor == 0 {
121-
// /dev/tty0 is the current virtual console
122-
Ok(Self::Tty(0))
123-
} else {
124-
Ok(Self::Tty(minor))
125-
}
126-
}
119+
4 => Ok(Self::Tty(minor)),
127120
// Serial terminals (/dev/ttyS0, /dev/ttyS1, etc.)
128121
5 => Ok(Self::TtyS(minor)),
129122
// Pseudo-terminals (/dev/pts/0, /dev/pts/1, etc.)

0 commit comments

Comments
 (0)