Skip to content

Commit

Permalink
lslocks: Small code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrv committed Feb 21, 2025
1 parent 9dd6bc1 commit ee14c44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ feat_common_core = [
"setsid",
]

[workspace]
members = ["src/uu/lslocks"]

[workspace.dependencies]
clap = { version = "4.4", features = ["wrap_help", "cargo"] }
clap_complete = "4.4"
Expand Down
14 changes: 7 additions & 7 deletions src/uu/lslocks/src/lslocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Lock {
Column::Type => self.lock_type.to_string(),
Column::Size => todo!(),
Column::Inode => self.inode.to_string(),
Column::MajMin => self.major_minor.clone(),
Column::MajorMinor => self.major_minor.clone(),
Column::Mode => self.mode.to_string(),
Column::Mandatory => {
if self.mandatory {
Expand Down Expand Up @@ -94,10 +94,10 @@ impl FromStr for Lock {
};

// This field has a format of MAJOR:MINOR:INODE
let maj_min_inode: Vec<_> = parts.next().unwrap().split(":").collect();
assert_eq!(maj_min_inode.len(), 3);
let major_minor = [maj_min_inode[0], maj_min_inode[1]].join(":");
let inode = maj_min_inode[2].parse::<usize>().unwrap();
let major_minor_inode: Vec<_> = parts.next().unwrap().split(":").collect();
assert_eq!(major_minor_inode.len(), 3);
let major_minor = [major_minor_inode[0], major_minor_inode[1]].join(":");
let inode = major_minor_inode[2].parse::<usize>().unwrap();

let start_offset = parts.next().unwrap().parse::<usize>().unwrap();
let end_offset: Option<usize> = parts.next().and_then(|offset_str| match offset_str {
Expand Down Expand Up @@ -184,7 +184,7 @@ enum Column {
Type,
Size,
Inode,
MajMin,
MajorMinor,
Mode,
Mandatory,
Start,
Expand All @@ -202,7 +202,7 @@ impl Column {
Self::Type => "TYPE",
Self::Size => "SIZE",
Self::Inode => "INODE",
Self::MajMin => "MAJ:MIN",
Self::MajorMinor => "MAJ:MIN",
Self::Mode => "MODE",
Self::Mandatory => "M",
Self::Start => "START",
Expand Down

0 comments on commit ee14c44

Please sign in to comment.