Skip to content

Commit 5f997a7

Browse files
committed
cmd/podman/pods/create: fix break statement
This code was [somewhat messy but] correct until commit 51fbf3d started to use switch instead of if, and since that time break is breaking from the inner "switch" (rather than on the outer "for" as originally intended). This also fixes the following staticcheck warnings: > cmd/podman/pods/create.go:242:5: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck) > break > ^ > cmd/podman/pods/create.go:245:5: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck) > break > ^ Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 2a9b149 commit 5f997a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/podman/pods/create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,17 @@ func create(cmd *cobra.Command, args []string) error {
233233
}
234234
}
235235
sort.Ints(vals)
236+
loop:
236237
for ind, core := range vals {
237238
switch {
238239
case core > int(cpuSet):
239240
if copy == "" {
240241
copy = "0-" + strconv.Itoa(int(cpuSet))
241242
infraOptions.CPUSetCPUs = copy
242-
break
243243
} else {
244244
infraOptions.CPUSetCPUs = copy
245-
break
246245
}
246+
break loop
247247
case ind != 0:
248248
copy += "," + strconv.Itoa(core)
249249
default:
@@ -252,6 +252,7 @@ func create(cmd *cobra.Command, args []string) error {
252252
}
253253
createOptions.Cpus = infraOptions.CPUS
254254
createOptions.CpusetCpus = infraOptions.CPUSetCPUs
255+
255256
podSpec := specgen.NewPodSpecGenerator()
256257
podSpec, err = entities.ToPodSpecGen(*podSpec, &createOptions)
257258
if err != nil {

0 commit comments

Comments
 (0)