Fix ifElseChain lint errors

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-08-29 10:12:45 +02:00
parent 48d68e4eff
commit acc50969dc
4 changed files with 21 additions and 16 deletions

View File

@ -193,14 +193,15 @@ func (c testConfig) getRuntimeSpec() (specs.Spec, error) {
defer jsonFile.Close()
jsonContent, err := io.ReadAll(jsonFile)
if err != nil {
switch {
case err != nil:
return spec, err
} else if json.Valid(jsonContent) {
case json.Valid(jsonContent):
err = json.Unmarshal(jsonContent, &spec)
if err != nil {
return spec, err
}
} else {
default:
err = json.NewDecoder(bytes.NewReader(jsonContent)).Decode(&spec)
if err != nil {
return spec, err

View File

@ -152,12 +152,13 @@ func TestModify(t *testing.T) {
err := spec.Modify(modifier{tc.modifierError})
if tc.spec == nil {
switch {
case tc.spec == nil:
require.Error(t, err, "%d: %v", i, tc)
} else if tc.modifierError != nil {
case tc.modifierError != nil:
require.EqualError(t, err, tc.modifierError.Error(), "%d: %v", i, tc)
require.EqualValues(t, &specs.Spec{}, spec.Spec, "%d: %v", i, tc)
} else {
default:
require.NoError(t, err, "%d: %v", i, tc)
require.Equal(t, "updated", spec.Spec.Version, "%d: %v", i, tc)
}

View File

@ -80,19 +80,20 @@ func (d symlinkHook) getSpecificLinks() ([]string, error) {
lib := filepath.Base(m.Path)
if strings.HasPrefix(lib, "libcuda.so") {
switch {
case strings.HasPrefix(lib, "libcuda.so"):
// XXX Many applications wrongly assume that libcuda.so exists (e.g. with dlopen).
target = "libcuda.so.1"
link = "libcuda.so"
} else if strings.HasPrefix(lib, "libGLX_nvidia.so") {
case strings.HasPrefix(lib, "libGLX_nvidia.so"):
// XXX GLVND requires this symlink for indirect GLX support.
target = lib
link = "libGLX_indirect.so.0"
} else if strings.HasPrefix(lib, "libnvidia-opticalflow.so") {
case strings.HasPrefix(lib, "libnvidia-opticalflow.so"):
// XXX Fix missing symlink for libnvidia-opticalflow.so.
target = "libnvidia-opticalflow.so.1"
link = "libnvidia-opticalflow.so"
} else {
default:
continue
}
if linkProcessed[link] {

View File

@ -104,11 +104,12 @@ func (l *Logger) Update(filename string, logLevel string, argv []string) {
newLogger.SetFormatter(new(logrus.JSONFormatter))
}
if len(logFiles) == 0 {
switch len(logFiles) {
case 0:
newLogger.SetOutput(io.Discard)
} else if len(logFiles) == 1 {
case 1:
newLogger.SetOutput(logFiles[0])
} else if len(logFiles) > 1 {
default:
var writers []io.Writer
for _, f := range logFiles {
writers = append(writers, f)
@ -234,12 +235,13 @@ func parseArgs(args []string) loggerConfig {
}
var value string
if len(parts) == 2 {
switch {
case len(parts) == 2:
value = parts[2]
} else if i+1 < len(args) {
case i+1 < len(args):
value = args[i+1]
i++
} else {
default:
continue
}