Discussion:
[Libstoragemgmt-devel] [PATCH] fix error return value
Ma Shimiao
2014-02-13 09:28:56 UTC
Permalink
A small fix.
When err is NULL, we should tell user the real error reason.

Signed-off-by: Ma Shimiao <***@cn.fujitsu.com>
---
src/lsm_mgmt.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index 694e10a..538fc7e 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -121,8 +121,9 @@ static lsmErrorNumber logException(lsmConnect *c, lsmErrorNumber error,
NULL, 0);
if( err ) {
lsmErrorLog(c, err);
+ return error;
}
- return error;
+ return LSM_ERR_NO_MEMORY;
}

static int rpc(lsmConnect *c, const char *method, const Value &parameters,
--
1.8.3.1
Tony Asleson
2014-02-17 16:57:35 UTC
Permalink
Post by Ma Shimiao
A small fix.
When err is NULL, we should tell user the real error reason.
The existing code is returning the real error reason. With this change
we would now be losing the fact that when trying to log an error we had
a memory allocation failure and reported that instead.

In my opinion I would rather report the original error than report we
ran of of memory trying to log it.

Regards,
Tony
Post by Ma Shimiao
---
src/lsm_mgmt.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index 694e10a..538fc7e 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -121,8 +121,9 @@ static lsmErrorNumber logException(lsmConnect *c, lsmErrorNumber error,
NULL, 0);
if( err ) {
lsmErrorLog(c, err);
+ return error;
}
- return error;
+ return LSM_ERR_NO_MEMORY;
}
static int rpc(lsmConnect *c, const char *method, const Value &parameters,
MaShimiao
2014-02-18 00:52:56 UTC
Permalink
Post by Tony Asleson
Post by Ma Shimiao
A small fix.
When err is NULL, we should tell user the real error reason.
The existing code is returning the real error reason. With this change
we would now be losing the fact that when trying to log an error we had
a memory allocation failure and reported that instead.
In my opinion I would rather report the original error than report we
ran of of memory trying to log it.
Fine. Got it.

Best Regards,
Post by Tony Asleson
Regards,
Tony
Post by Ma Shimiao
---
src/lsm_mgmt.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index 694e10a..538fc7e 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -121,8 +121,9 @@ static lsmErrorNumber logException(lsmConnect *c, lsmErrorNumber error,
NULL, 0);
if( err ) {
lsmErrorLog(c, err);
+ return error;
}
- return error;
+ return LSM_ERR_NO_MEMORY;
}
static int rpc(lsmConnect *c, const char *method, const Value &parameters,
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Libstoragemgmt-devel mailing list
https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel
Loading...