From a73610dc4fe8876c4e38f0feab2b629c11a4f244 Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Wed, 7 Aug 2024 02:27:21 +0000 Subject: [PATCH] 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 Fixes: #5321 (cherry picked from commit 73e78a5822224bd7640888b6b5c2ab6b3f35bd13) Signed-off-by: Sebastiaan van Stijn --- opts/throttledevice.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opts/throttledevice.go b/opts/throttledevice.go index bdf454eb27da..8bf128804794 100644 --- a/opts/throttledevice.go +++ b/opts/throttledevice.go @@ -94,7 +94,7 @@ func (opt *ThrottledeviceOpt) String() string { // GetList returns a slice of pointers to ThrottleDevices. 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) return out }