cephfs: add a getErrorIfNegative helper func

Works like the ones already in the other packages.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-06-18 13:35:35 -04:00 committed by John Mulligan
parent 837777d3fc
commit 65227dd4d4
1 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,16 @@ func getError(e C.int) error {
return cephFSError(e)
}
// getErrorIfNegative converts a ceph return code to error if negative.
// This is useful for functions that return a usable positive value on
// success but a negative error number on error.
func getErrorIfNegative(ret C.int) error {
if ret >= 0 {
return nil
}
return getError(ret)
}
// Public go errors:
var (