libcontainer/configs/validate: use early return

...in intelrdtCheck, like all other checks already do.

Best reviewed with --ignore-all-space.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2026-04-23 16:16:40 -07:00
parent 8d1ebab374
commit 48c7e83b91
+15 -14
View File
@@ -306,22 +306,23 @@ func sysctl(config *configs.Config) error {
}
func intelrdtCheck(config *configs.Config) error {
if config.IntelRdt != nil {
if !intelRdt.isEnabled() {
return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled")
}
if config.IntelRdt == nil {
return nil
}
if !intelRdt.isEnabled() {
return fmt.Errorf("intelRdt is specified in config, but Intel RDT is not enabled")
}
switch clos := config.IntelRdt.ClosID; {
case clos == ".", clos == "..", len(clos) > 1 && strings.Contains(clos, "/"):
return fmt.Errorf("invalid intelRdt.ClosID %q", clos)
}
switch clos := config.IntelRdt.ClosID; {
case clos == ".", clos == "..", len(clos) > 1 && strings.Contains(clos, "/"):
return fmt.Errorf("invalid intelRdt.ClosID %q", clos)
}
if !intelRdt.isCATEnabled() && config.IntelRdt.L3CacheSchema != "" {
return errors.New("intelRdt.l3CacheSchema is specified in config, but Intel RDT/CAT is not enabled")
}
if !intelRdt.isMBAEnabled() && config.IntelRdt.MemBwSchema != "" {
return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled")
}
if !intelRdt.isCATEnabled() && config.IntelRdt.L3CacheSchema != "" {
return errors.New("intelRdt.l3CacheSchema is specified in config, but Intel RDT/CAT is not enabled")
}
if !intelRdt.isMBAEnabled() && config.IntelRdt.MemBwSchema != "" {
return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled")
}
return nil