fix: fix slice init length (#21349)

Co-authored-by: cui fliter <imcusg@gmail.com>
This commit is contained in:
wanyaoqi
2024-10-07 20:09:28 +08:00
committed by GitHub
co-authored by cui fliter
parent 2c51ca5e1e
commit ceff4b7330
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)
}