libpod: do not reuse names slice

Do not reuse names slice for the unrelated data. This fixes the
following prealoc warning:

> libpod/storage.go:109:2: Consider preallocating names with capacity 2 (prealloc)
> 	names := []string{containerName}
> 	^

This commit is part of series fixing issues reported by prealloc linter
from golangci-lint v2.8.0.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2026-02-05 16:43:29 -08:00
parent 2a99655120
commit 3c3d32718f

View File

@@ -106,9 +106,7 @@ func (r *storageService) CreateContainerStorage(ctx context.Context, systemConte
}
// Build the container.
names := []string{containerName}
container, err := r.store.CreateContainer(containerID, names, imageID, "", string(mdata), &options)
container, err := r.store.CreateContainer(containerID, []string{containerName}, imageID, "", string(mdata), &options)
if err != nil {
logrus.Debugf("Failed to create container %s(%s): %v", metadata.ContainerName, containerID, err)
@@ -132,7 +130,7 @@ func (r *storageService) CreateContainerStorage(ctx context.Context, systemConte
// Add a name to the container's layer so that it's easier to follow
// what's going on if we're just looking at the storage-eye view of things.
layerName := metadata.ContainerName + "-layer"
names, err = r.store.Names(container.LayerID)
names, err := r.store.Names(container.LayerID)
if err != nil {
return ContainerInfo{}, err
}