run: fix GetList return empty issue for throttledevice

Test "--device-read-bps" "--device-write-bps" will fail. The root
cause is that GetList helper return empty as its local variable
initialized to zero size.

This patch fix it by setting the related slice size to non-zero.

Signed-off-by: Jianyong Wu <wujianyong@hygon.cn>
Fixes: #5321
This commit is contained in:
Jianyong Wu 2024-08-07 02:27:21 +00:00
Родитель 78de7da660
Коммит 73e78a5822
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -94,7 +94,7 @@ func (opt *ThrottledeviceOpt) String() string {
// GetList returns a slice of pointers to ThrottleDevices. // GetList returns a slice of pointers to ThrottleDevices.
func (opt *ThrottledeviceOpt) GetList() []*blkiodev.ThrottleDevice { func (opt *ThrottledeviceOpt) GetList() []*blkiodev.ThrottleDevice {
out := make([]*blkiodev.ThrottleDevice, 0, len(opt.values)) out := make([]*blkiodev.ThrottleDevice, len(opt.values))
copy(out, opt.values) copy(out, opt.values)
return out return out
} }