Skip to content

Commit

Permalink
fix: fix slice init length (#21346)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuishuang authored Oct 7, 2024
1 parent cc94930 commit 060f6a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/hostman/diskutils/qemu_kvm/lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (d *LocalDiskDriver) getVgLvs(vg string) ([]LvProps, error) {
if len(res.Report) != 1 {
return nil, errors.Errorf("unexpect res %v", res)
}
lvs := make([]LvProps, len(res.Report[0].LV))
lvs := make([]LvProps, 0, len(res.Report[0].LV))
for i := 0; i < len(res.Report[0].LV); i++ {
if res.Report[0].LV[i].LVName == "" {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/hostman/storageman/lvmutils/lvmutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func GetLvNames(vg string) ([]string, error) {
if len(res.Report) != 1 {
return nil, errors.Errorf("unexpect res %v", res)
}
lvNames := make([]string, len(res.Report[0].LV))
lvNames := make([]string, 0, len(res.Report[0].LV))
for i := 0; i < len(res.Report[0].LV); i++ {
lvNames = append(lvNames, res.Report[0].LV[i].LVName)
}
Expand Down

0 comments on commit 060f6a6

Please sign in to comment.