fix new lint issues from prealloc

Fix a few new issues reported by the linter update.

There is no need to copy the capAdd/capDrop slice in the compat create
endpoint as they are only read and not modified.
For the other code preallocate the slices so we safe memory allocations.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2026-03-10 19:21:52 +01:00
parent 1c21eed0fb
commit 4f1d4ae8a0
4 changed files with 9 additions and 9 deletions

View File

@@ -62,7 +62,6 @@ func GetDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *d
}
func GetDebugDevices() ([]vfConfig.VirtioDevice, error) {
var devices []vfConfig.VirtioDevice
gpu, err := vfConfig.VirtioGPUNew()
if err != nil {
return nil, err
@@ -75,7 +74,7 @@ func GetDebugDevices() ([]vfConfig.VirtioDevice, error) {
if err != nil {
return nil, err
}
return append(devices, gpu, mouse, kb), nil
return []vfConfig.VirtioDevice{gpu, mouse, kb}, nil
}
func GetIgnitionVsockDevice(path string) (vfConfig.VirtioDevice, error) {

View File

@@ -28,7 +28,8 @@ type QemuCmd []string
// starting with the qemu binary, architecture specific options, and propagated
// proxy and SSL settings
func NewQemuBuilder(binary string, options []string) QemuCmd {
q := QemuCmd{binary}
q := make(QemuCmd, 0, 1+len(options))
q = append(q, binary)
return append(q, options...)
}