From bb375f68acc5c543b7361db8734d92bae4c41961 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 20 Dec 2019 13:37:10 -0500 Subject: [PATCH] rados: convert less-than-zero error checks to getRadosError A number of the error handling checks do not seem to need to check for specific non-zero error returns so we should be able to convert to getRadosError rather than a lot of boiler-plate. Signed-off-by: John Mulligan --- rados/conn.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/rados/conn.go b/rados/conn.go index ff2182a..815f3c3 100644 --- a/rados/conn.go +++ b/rados/conn.go @@ -128,11 +128,7 @@ func (c *Conn) SetConfigOption(option, value string) error { defer C.free(unsafe.Pointer(c_opt)) defer C.free(unsafe.Pointer(c_val)) ret := C.rados_conf_set(c.cluster, c_opt, c_val) - if ret < 0 { - return RadosError(int(ret)) - } else { - return nil - } + return getRadosError(int(ret)) } // GetConfigOption returns the value of the Ceph configuration option @@ -158,11 +154,7 @@ func (c *Conn) GetConfigOption(name string) (value string, err error) { // retrieved. func (c *Conn) WaitForLatestOSDMap() error { ret := C.rados_wait_for_latest_osdmap(c.cluster) - if ret < 0 { - return RadosError(int(ret)) - } else { - return nil - } + return getRadosError(int(ret)) } func (c *Conn) ensure_connected() error { @@ -210,11 +202,7 @@ func (c *Conn) ParseCmdLineArgs(args []string) error { } ret := C.rados_conf_parse_argv(c.cluster, argc, &argv[0]) - if ret < 0 { - return RadosError(int(ret)) - } else { - return nil - } + return getRadosError(int(ret)) } // ParseDefaultConfigEnv configures the connection from the default Ceph