From d9fdfc543dd2e14154fbe4a06f648b050f2657ba Mon Sep 17 00:00:00 2001 From: cuishuang Date: Fri, 4 Oct 2024 01:44:34 +0800 Subject: [PATCH] fix: fix slice init length Signed-off-by: cuishuang --- internal/server/network/ovn/ovn_icsb_actions.go | 2 +- internal/server/storage/drivers/driver_ceph_volumes.go | 2 +- internal/server/storage/drivers/driver_lvm_volumes.go | 2 +- internal/server/storage/drivers/driver_zfs_volumes.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/server/network/ovn/ovn_icsb_actions.go b/internal/server/network/ovn/ovn_icsb_actions.go index a26d0cc3760..a96771e1167 100644 --- a/internal/server/network/ovn/ovn_icsb_actions.go +++ b/internal/server/network/ovn/ovn_icsb_actions.go @@ -30,7 +30,7 @@ func (o *ICSB) GetGateways(ctx context.Context, name string) ([]string, error) { } // Extract the names. - names := make([]string, len(gateways)) + names := make([]string, 0, len(gateways)) for _, entry := range gateways { names = append(names, entry.Name) } diff --git a/internal/server/storage/drivers/driver_ceph_volumes.go b/internal/server/storage/drivers/driver_ceph_volumes.go index 150b814f009..25989d31d3d 100644 --- a/internal/server/storage/drivers/driver_ceph_volumes.go +++ b/internal/server/storage/drivers/driver_ceph_volumes.go @@ -1173,7 +1173,7 @@ func (d *ceph) ListVolumes() ([]Volume, error) { return nil, fmt.Errorf("Failed getting volume list: %v: %w", strings.TrimSpace(string(errMsg)), err) } - volList := make([]Volume, len(vols)) + volList := make([]Volume, 0, len(vols)) for _, v := range vols { volList = append(volList, v) } diff --git a/internal/server/storage/drivers/driver_lvm_volumes.go b/internal/server/storage/drivers/driver_lvm_volumes.go index 696e3280001..56c04e60823 100644 --- a/internal/server/storage/drivers/driver_lvm_volumes.go +++ b/internal/server/storage/drivers/driver_lvm_volumes.go @@ -684,7 +684,7 @@ func (d *lvm) ListVolumes() ([]Volume, error) { return nil, fmt.Errorf("Failed getting volume list: %v: %w", strings.TrimSpace(string(errMsg)), err) } - volList := make([]Volume, len(vols)) + volList := make([]Volume, 0, len(vols)) for _, v := range vols { volList = append(volList, v) } diff --git a/internal/server/storage/drivers/driver_zfs_volumes.go b/internal/server/storage/drivers/driver_zfs_volumes.go index 6905d01dad0..40c480c19a5 100644 --- a/internal/server/storage/drivers/driver_zfs_volumes.go +++ b/internal/server/storage/drivers/driver_zfs_volumes.go @@ -2043,7 +2043,7 @@ func (d *zfs) ListVolumes() ([]Volume, error) { return nil, fmt.Errorf("Failed getting volume list: %v: %w", strings.TrimSpace(string(errMsg)), err) } - volList := make([]Volume, len(vols)) + volList := make([]Volume, 0, len(vols)) for _, v := range vols { volList = append(volList, v) }