Skip to content

Commit

Permalink
sysfs: return sensible result when no valid data read
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Apr 22, 2017
1 parent c1121af commit 471c526
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sysfs/pwm_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func (p *PWMPin) Period() (period string, err error) {
if err != nil {
return
}
if len(buf) == 0 {
return "0", nil
}
return string(buf), nil
}

Expand Down Expand Up @@ -166,7 +169,7 @@ func readPwmFile(path string) ([]byte, error) {
var i int
i, err = file.Read(buf)
if i == 0 {
return buf, err
return []byte{}, err
}
return buf[:i], err
}

0 comments on commit 471c526

Please sign in to comment.