Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
device: Add extra checks
Browse files Browse the repository at this point in the history
Add parameter checks to `waitForDevice()`.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Jul 18, 2019
1 parent faa6cb0 commit d4f205d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package main

import (
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -288,6 +289,18 @@ func updateSpecDeviceList(device pb.Device, spec *pb.Spec) error {
type checkUeventCb func(uEv *uevent.Uevent) bool

func waitForDevice(devicePath, deviceName string, checkUevent checkUeventCb) error {
if devicePath == "" {
return errors.New("need device path")
}

if deviceName == "" {
return errors.New("need device name")
}

if checkUevent == nil {
return errors.New("invalid uevent handler")
}

uEvHandler, err := uevent.NewHandler()
if err != nil {
return err
Expand Down

0 comments on commit d4f205d

Please sign in to comment.