Skip to content

Commit

Permalink
Fix if condition for nice value check
Browse files Browse the repository at this point in the history
Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
  • Loading branch information
YJDoc2 committed Jan 21, 2024
1 parent 8a0224c commit ee4a32e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/libcontainer/src/container/tenant_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,17 @@ impl TenantContainerBuilder {
let policy = sc.policy();
if let Some(nice) = sc.nice() {
// https://man7.org/linux/man-pages/man2/sched_setattr.2.html#top_of_page
if (*policy != LinuxSchedulerPolicy::SchedBatch
|| *policy != LinuxSchedulerPolicy::SchedOther)
&& *nice < -20
&& *nice > 19
if *policy == LinuxSchedulerPolicy::SchedBatch

Check failure on line 230 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (x86_64, gnu)

this `if` statement can be collapsed

Check failure on line 230 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (x86_64, musl)

this `if` statement can be collapsed

Check failure on line 230 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, gnu)

this `if` statement can be collapsed

Check failure on line 230 in crates/libcontainer/src/container/tenant_builder.rs

View workflow job for this annotation

GitHub Actions / check (aarch64, musl)

this `if` statement can be collapsed
|| *policy == LinuxSchedulerPolicy::SchedOther
{
tracing::error!(?nice, "invalid scheduler.nice: '{}'", nice);
Err(ErrInvalidSpec::Scheduler)?;
if *nice < -20 || *nice > 19 {
tracing::error!(
?nice,
"invalid scheduler.nice: '{}', must be within -20 to 19",
nice
);
Err(ErrInvalidSpec::Scheduler)?;
}
}
}
if let Some(priority) = sc.priority() {
Expand Down

0 comments on commit ee4a32e

Please sign in to comment.