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 bac336d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions config/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@ 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 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]
} else {
// Intermediate part, find or create the menu
currentMenu := cm.FindOrCreateMenu(currentMenus, part)
currentMenus = &currentMenu.Menus
}
}

return nil
}

Expand Down

0 comments on commit bac336d

Please sign in to comment.