diff --git a/events.go b/events.go index 53e8c028f..28d324984 100644 --- a/events.go +++ b/events.go @@ -199,7 +199,7 @@ func convertMemoryEntry(c cgroups.MemoryData) types.MemoryEntry { } func convertBlkioEntry(c []cgroups.BlkioStatEntry) []types.BlkioEntry { - var out []types.BlkioEntry + out := make([]types.BlkioEntry, 0, len(c)) for _, e := range c { out = append(out, types.BlkioEntry(e)) } diff --git a/libcontainer/internal/userns/usernsfd_linux.go b/libcontainer/internal/userns/usernsfd_linux.go index a1151a3fb..35ac373cd 100644 --- a/libcontainer/internal/userns/usernsfd_linux.go +++ b/libcontainer/internal/userns/usernsfd_linux.go @@ -41,10 +41,11 @@ func (m Mapping) toSys() (uids, gids []syscall.SysProcIDMap) { // the uid and gid mappings (because the order doesn't matter to the kernel). // The set of userns handles is indexed using this ID. func (m Mapping) id() string { - var uids, gids []string + uids := make([]string, 0, len(m.UIDMappings)) for _, idmap := range m.UIDMappings { uids = append(uids, fmt.Sprintf("%d:%d:%d", idmap.ContainerID, idmap.HostID, idmap.Size)) } + gids := make([]string, 0, len(m.GIDMappings)) for _, idmap := range m.GIDMappings { gids = append(gids, fmt.Sprintf("%d:%d:%d", idmap.ContainerID, idmap.HostID, idmap.Size)) }