Skip to content

Commit

Permalink
change variable name to something better
Browse files Browse the repository at this point in the history
Signed-off-by: amghazanfari <[email protected]>
  • Loading branch information
amghazanfari committed Sep 19, 2024
1 parent e0c62bd commit 59123be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions libcontainer/cgroups/fs/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ func getPageUsageByNUMA(path string) (cgroups.PageUsageByNUMA, error) {
line := scanner.Text()
columns := strings.SplitN(line, " ", maxColumns)
for i, column := range columns {
key, val, isValidNumaStats := strings.Cut(column, "=")
key, val, ok := strings.Cut(column, "=")
// Some custom kernels have non-standard fields, like
// numa_locality 0 0 0 0 0 0 0 0 0 0
// numa_exectime 0
if !isValidNumaStats {
if !ok {
if i != 0 {
// The first column was already validated,
// so be strict to the rest.
Expand Down
10 changes: 5 additions & 5 deletions libcontainer/cgroups/systemd/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func RangeToBits(str string) ([]byte, error) {
if r == "" {
continue
}
startRange, endRange, doesHaveEnd := strings.Cut(r, "-")
if doesHaveEnd {
start, err := strconv.ParseUint(startRange, 10, 32)
startr, endr, ok := strings.Cut(r, "-")
if ok {
start, err := strconv.ParseUint(startr, 10, 32)
if err != nil {
return nil, err
}
end, err := strconv.ParseUint(endRange, 10, 32)
end, err := strconv.ParseUint(endr, 10, 32)
if err != nil {
return nil, err
}
Expand All @@ -38,7 +38,7 @@ func RangeToBits(str string) ([]byte, error) {
bits.SetBit(bits, int(i), 1)
}
} else {
val, err := strconv.ParseUint(startRange, 10, 32)
val, err := strconv.ParseUint(startr, 10, 32)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
// current processes's environment.
func populateProcessEnvironment(env []string) error {
for _, pair := range env {
name, val, isValidEnv := strings.Cut(pair, "=")
if !isValidEnv {
name, val, ok := strings.Cut(pair, "=")
if !ok {
return errors.New("invalid environment variable: missing '='")
}
if name == "" {
Expand Down
4 changes: 2 additions & 2 deletions libcontainer/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func SearchLabels(labels []string, key string) (string, bool) {
func Annotations(labels []string) (bundle string, userAnnotations map[string]string) {
userAnnotations = make(map[string]string)
for _, l := range labels {
name, value, isValidAnnotation := strings.Cut(l, "=")
if !isValidAnnotation {
name, value, ok := strings.Cut(l, "=")
if !ok {
continue
}
if name == "bundle" {
Expand Down

0 comments on commit 59123be

Please sign in to comment.