Trim whitespace from input string before parsing in `OomScoreAdhFileOps::write_at` method
This commit is contained in:
parent
a599a2c563
commit
01cf00a4c6
|
|
@ -43,6 +43,7 @@ impl FileOps for OomScoreAdjFileOps {
|
||||||
let val = cstr
|
let val = cstr
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok()
|
.ok()
|
||||||
|
.map(|str| str.trim())
|
||||||
.and_then(|str| str.parse::<i32>().ok())
|
.and_then(|str| str.parse::<i32>().ok())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
Error::with_message(Errno::EINVAL, "the value is not a valid integer")
|
Error::with_message(Errno::EINVAL, "the value is not a valid integer")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue