From 060f6a65e80ba72f94d16cf010872fa10bb6a1eb Mon Sep 17 00:00:00 2001 From: cui fliter Date: Mon, 7 Oct 2024 21:41:07 +0800 Subject: [PATCH] fix: fix slice init length (#21346) --- pkg/hostman/diskutils/qemu_kvm/lvm.go | 2 +- pkg/hostman/storageman/lvmutils/lvmutils.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hostman/diskutils/qemu_kvm/lvm.go b/pkg/hostman/diskutils/qemu_kvm/lvm.go index 01dda5dca9..2423ef9f58 100644 --- a/pkg/hostman/diskutils/qemu_kvm/lvm.go +++ b/pkg/hostman/diskutils/qemu_kvm/lvm.go @@ -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 diff --git a/pkg/hostman/storageman/lvmutils/lvmutils.go b/pkg/hostman/storageman/lvmutils/lvmutils.go index 56e675d28f..b918e142b7 100644 --- a/pkg/hostman/storageman/lvmutils/lvmutils.go +++ b/pkg/hostman/storageman/lvmutils/lvmutils.go @@ -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) }