Skip to content

Commit

Permalink
config/supermicro.go: Refactor FindOrCreateSetting to avoid premature…
Browse files Browse the repository at this point in the history
… loop exit
  • Loading branch information
splaspood committed Jul 18, 2024
1 parent e7cce54 commit 168c36c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions config/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ func (cm *supermicroVendorConfig) FindOrCreateSetting(path []string, value strin
return (*currentMenus)[j].Settings[k]
}
}

newSetting := &supermicroBiosCfgSetting{Name: part, SelectedOption: value}
(*currentMenus)[j].Settings = append((*currentMenus)[j].Settings, newSetting)
return (*currentMenus)[j].Settings[len((*currentMenus)[j].Settings)-1]
// If we reach here, the setting was not found in this menu
}

Check failure on line 82 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

block should not end with a whitespace (or comment) (wsl)

Check failure on line 82 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

block should not end with a whitespace (or comment) (wsl)

Check failure on line 82 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

block should not end with a whitespace (or comment) (wsl)

Check failure on line 82 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

block should not end with a whitespace (or comment) (wsl)
// If no setting found in any menu, create a new setting in the first menu
newSetting := supermicroBiosCfgSetting{Name: part, SelectedOption: ""}
(*currentMenus)[0].Settings = append((*currentMenus)[0].Settings, &newSetting)
return (*currentMenus)[0].Settings[len((*currentMenus)[0].Settings)-1]

Check failure on line 86 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

return statements should not be cuddled if block has more than two lines (wsl)

Check failure on line 86 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

return statements should not be cuddled if block has more than two lines (wsl)

Check failure on line 86 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

return statements should not be cuddled if block has more than two lines (wsl)

Check failure on line 86 in config/supermicro.go

View workflow job for this annotation

GitHub Actions / lint

return statements should not be cuddled if block has more than two lines (wsl)
} else {
// Intermediate part, find or create the menu
currentMenu := cm.FindOrCreateMenu(currentMenus, part)
currentMenus = &currentMenu.Menus
}
}

return nil
}

Expand Down

0 comments on commit 168c36c

Please sign in to comment.