From: Chris B. <buc...@us...> - 2012-05-19 00:24:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "SFCB - Small Footprint CIM Broker". The branch, master has been updated via 87f9c4a243f5040f7dbe778c036df6d738c85061 (commit) via 1f71a3a5030982bc22b3d1f6ead1da7d26faf892 (commit) from f72ae66b66102b892ded4ba2fd4a17330f23662d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 87f9c4a243f5040f7dbe778c036df6d738c85061 Author: buccella <buc...@li...> Date: Fri May 18 20:24:24 2012 -0400 [ 3528096 ] Error status codes sometimes not propigated for instances commit 1f71a3a5030982bc22b3d1f6ead1da7d26faf892 Author: buccella <buc...@li...> Date: Fri May 18 20:23:30 2012 -0400 [ 3528074 ] Improve CMPIInstance Error Codes ----------------------------------------------------------------------- Summary of changes: diff --git a/ChangeLog b/ChangeLog index 43d757d..1aa3f86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2012-05-18 Chris Buccella <buc...@li...> + + * objectImpl.c: + [ 3528096 ] Error status codes sometimes not propigated for instances + (patch by Tyrel Datwyler) + + * instance.c, test/TestProviders/cmpiTestMiscProvider.c, + test/TestProviders/test/TestMisc8.lines: + [ 3528074 ] Improve CMPIInstance Error Codes + (patch by Tyrel Datwyler) + 2012-05-18 Narasimha Sharoff <nsh...@us...> * indCIMXMLHander.c: diff --git a/NEWS b/NEWS index 7982dba..3dfeb98 100644 --- a/NEWS +++ b/NEWS @@ -105,6 +105,8 @@ Bugs Fixed: - 3525651 CMSetPropertyFilter not CMPI 2.0 compliant - 3527693 Property filters don't work for enum upcalls - 3524819 sfcb may hang on ac call to indication subscription +- 3528074 Improve CMPIInstance Error Codes +- 3528096 Error status codes sometimes not propigated for instances Changes in 1.3.14 ================= diff --git a/instance.c b/instance.c index 059d98c..953fea4 100644 --- a/instance.c +++ b/instance.c @@ -164,6 +164,10 @@ __ift_release(CMPIInstance *instance) { struct native_instance *i = (struct native_instance *) instance; + if (!instance->hdl) { + CMReturn(CMPI_RC_ERR_INVALID_HANDLE); + } + if (i->mem_state && i->mem_state != MEM_RELEASED) { __release_list(i->property_list); __release_list(i->key_list); @@ -180,8 +184,15 @@ static CMPIInstance * __ift_clone(const CMPIInstance *instance, CMPIStatus *rc) { struct native_instance *i = (struct native_instance *) instance; - struct native_instance *new = (struct native_instance *) - malloc(sizeof(struct native_instance)); + struct native_instance *new; + + if (!instance->hdl) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); + return NULL; + } + + new = (struct native_instance*) malloc(sizeof(struct native_instance)); new->refCount = 0; new->mem_state = MEM_NOT_TRACKED; @@ -193,6 +204,8 @@ __ift_clone(const CMPIInstance *instance, CMPIStatus *rc) ClInstanceRebuild((ClInstance *) instance->hdl, NULL); ((CMPIInstance *) new)->ft = instance->ft; + if (rc) + CMSetStatus(rc, CMPI_RC_OK); return (CMPIInstance *) new; } @@ -204,7 +217,7 @@ __ift_internal_getPropertyAt(const CMPIInstance *ci, CMPICount i, CMPIData rv = { 0, CMPI_notFound, {0} }; if (ClInstanceGetPropertyAt(inst, i, &rv, name, NULL)) { if (rc) - CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY); return rv; } @@ -239,8 +252,16 @@ CMPIData __ift_getPropertyAt(const CMPIInstance *ci, CMPICount i, CMPIString **name, CMPIStatus *rc) { + CMPIData rv = { 0, CMPI_notFound, {0} }; char *sname; - CMPIData rv = __ift_internal_getPropertyAt(ci, i, &sname, rc, 0); + + if (!ci->hdl) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); + return rv; + } + + rv = __ift_internal_getPropertyAt(ci, i, &sname, rc, 0); if (name) { *name = sfcb_native_new_CMPIString(sname, NULL, 0); } @@ -250,17 +271,30 @@ __ift_getPropertyAt(const CMPIInstance *ci, CMPICount i, CMPIData __ift_getProperty(const CMPIInstance *ci, const char *id, CMPIStatus *rc) { - ClInstance *inst = (ClInstance *) ci->hdl; - ClSection *prps = &inst->properties; + ClInstance *inst; + ClSection *prps; CMPIData rv = { 0, CMPI_notFound, {0} }; int i; + if (!ci->hdl) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); + return rv; + } else if (!id) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY); + return rv; + } + + inst = (ClInstance *) ci->hdl; + prps = &inst->properties; + if ((i = ClObjectLocateProperty(&inst->hdr, prps, id)) != 0) { return __ift_getPropertyAt(ci, i - 1, NULL, rc); } if (rc) - CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY); return rv; } @@ -268,6 +302,13 @@ static CMPICount __ift_getPropertyCount(const CMPIInstance *ci, CMPIStatus *rc) { ClInstance *inst = (ClInstance *) ci->hdl; + + if (!ci->hdl) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); + return (CMPICount) 0; + } + if (rc) CMSetStatus(rc, CMPI_RC_OK); return (CMPICount) ClInstanceGetPropertyCount(inst); @@ -278,10 +319,16 @@ __ift_setProperty(const CMPIInstance *instance, const char *name, const CMPIValue * value, CMPIType type) { struct native_instance *i = (struct native_instance *) instance; - ClInstance *inst = (ClInstance *) instance->hdl; + ClInstance *inst; CMPIData data = { type, CMPI_goodValue, {0LL} }; int rc; + if (!instance->hdl) { + CMReturn(CMPI_RC_ERR_INVALID_HANDLE); + } + + inst = (ClInstance *) instance->hdl; + if (type == CMPI_chars) { /* * VM: is this OK or do we need a __new copy @@ -321,6 +368,7 @@ __ift_setProperty(const CMPIInstance *instance, ClInstanceFilterFlagProperty(inst, rc - 1); } if (rc < 0) + /* negative rc is a negated CMPI_RC_ERR return code */ CMReturn(-rc); } CMReturn(CMPI_RC_OK); @@ -355,6 +403,11 @@ __ift_setObjectPath(CMPIInstance *inst, const CMPIObjectPath * cop) int j; CMPIStatus rc = { CMPI_RC_OK, NULL }; + if (!inst->hdl) { + CMSetStatus(&rc, CMPI_RC_ERR_INVALID_HANDLE); + return rc; + } + /* in the case the instance is filtered need to reset the filter with new key list */ if (((struct native_instance *)inst)->filtered) { char **props = ((struct native_instance *)inst)->property_list; @@ -425,10 +478,17 @@ __ift_getObjectPath(const CMPIInstance *instance, CMPIStatus *rc) int j, f = 0; CMPIStatus tmp; - const char *cn = - ClInstanceGetClassName((ClInstance *) instance->hdl); - const char *ns = - ClInstanceGetNameSpace((ClInstance *) instance->hdl); + const char *cn; + const char *ns; + + if (!instance->hdl) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); + return NULL; + } + + cn = ClInstanceGetClassName((ClInstance *) instance->hdl); + ns = ClInstanceGetNameSpace((ClInstance *) instance->hdl); CMPIObjectPath *cop; cop = TrackedCMPIObjectPath(ns, cn, rc); @@ -568,7 +628,7 @@ static CMPIStatus __ift_setPropertyFilter(CMPIInstance * instance, /* NULL property list, no need to set filter */ CMReturn(CMPI_RC_OK); } - if (instance == NULL) { + if (!instance->hdl) { rc.rc = CMPI_RC_ERR_INVALID_HANDLE; } else { diff --git a/objectImpl.c b/objectImpl.c index b26f521..0bf198e 100644 --- a/objectImpl.c +++ b/objectImpl.c @@ -1678,7 +1678,7 @@ addObjectPropertyH(ClObjectHdr * hdr, ClSection * prps, else if (hdr->type == HDR_Instance && od.type == CMPI_instance && (d.state & CMPI_nullValue) == 0) { if (d.type != CMPI_instance) { - _SFCB_RETURN(CMPI_RC_ERR_TYPE_MISMATCH); + _SFCB_RETURN(-CMPI_RC_ERR_TYPE_MISMATCH); } else { (p + i - 1)->data = d; int size = getInstanceSerializedSize(d.value.inst); @@ -1697,7 +1697,7 @@ addObjectPropertyH(ClObjectHdr * hdr, ClSection * prps, else if (hdr->type == HDR_Args && od.type == CMPI_instance && (d.state & CMPI_nullValue) == 0) { if (d.type != CMPI_instance) { - _SFCB_RETURN(CMPI_RC_ERR_TYPE_MISMATCH); + _SFCB_RETURN(-CMPI_RC_ERR_TYPE_MISMATCH); } else { (p + i - 1)->data = d; diff --git a/test/TestProviders/cmpiTestMiscProvider.c b/test/TestProviders/cmpiTestMiscProvider.c index 337d8f9..6af9fc8 100644 --- a/test/TestProviders/cmpiTestMiscProvider.c +++ b/test/TestProviders/cmpiTestMiscProvider.c @@ -800,6 +800,7 @@ static int _testCMPIInstance() { CMPIStatus rc = { CMPI_RC_OK, NULL }; + int errors = 0; CMPIInstance *instance = NULL; CMPIInstance *clonedInstance = NULL; @@ -818,9 +819,6 @@ _testCMPIInstance() const char *name2 = "secondPropertyName"; CMPIValue value2; CMPIType type = CMPI_uint64; - CMPIBoolean dataEqual = 0; - CMPIBoolean objectPathEqual = 0; - CMPIBoolean cloneSuccessful = 0; CMPIString *beforeObjPath = NULL; CMPIString *afterObjPath = NULL; const char *beforeString = NULL; @@ -832,13 +830,18 @@ _testCMPIInstance() value2.uint32 = 20; rc = CMSetProperty(instance, name2, &value2, type); count = CMGetPropertyCount(instance, &rc); + /* count will vary based on what's in the MOF */ + if (count != 5) { + errors = 1; + } returnedData1 = CMGetProperty(instance, name1, &rc); - if (returnedData1.value.uint32 == 10) { - dataEqual = 1; + if (returnedData1.value.uint32 != 10) { + errors += 2; } - returnedData2 = CMGetPropertyAt(instance, 2, &returnedName, &rc); - if (returnedData2.value.uint32 == 20) { - dataEqual = 1; + /* this check is really SFCB-dependent, since position isn't guaranteed */ + returnedData2 = CMGetPropertyAt(instance, 0, &returnedName, &rc); + if (returnedData2.value.uint32 != 20) { + errors += 4; } newObjPath = make_ObjectPath(_broker, _Namespace, _ClassName); returnedObjPath = CMGetObjectPath(instance, &rc); @@ -850,28 +853,27 @@ _testCMPIInstance() afterObjPath = CMObjectPathToString(returnedObjPath, &rc); afterString = CMGetCharsPtr(afterObjPath, &rc); afterString = CMGetCharsPtr(CMGetNameSpace(returnedObjPath, &rc), &rc); - if (strcmp("newNamespace", afterString) == 0) { - objectPathEqual = 1; + if (strcmp("newNamespace", afterString) != 0) { + errors += 8; } clonedInstance = instance->ft->clone(instance, &rc); clonedData1 = CMGetProperty(clonedInstance, name1, &rc); rc = clonedInstance->ft->release(clonedInstance); - if (returnedData1.value.uint32 == clonedData1.value.uint32) { - cloneSuccessful = 1; - } else { - cloneSuccessful = 0; - } + if (returnedData1.value.uint32 != clonedData1.value.uint32) { + errors += 16; + } CMGetProperty(instance, "noProperty", &rc); if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) { - return 1; + errors += 32; } CMGetPropertyAt(instance, 100, &returnedName, &rc); if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) { - return 1; + errors += 64; } rc = instance->ft->release(instance); - return 0; + + return errors; } static int diff --git a/test/TestProviders/tests/TestMisc8.lines b/test/TestProviders/tests/TestMisc8.lines index 43491c3..76bb0b0 100644 --- a/test/TestProviders/tests/TestMisc8.lines +++ b/test/TestProviders/tests/TestMisc8.lines @@ -1,6 +1,6 @@ <METHODRESPONSE NAME="TestCMPIBroker"> <RETURNVALUE PARAMTYPE="uint32"> -<VALUE>1</VALUE> +<VALUE>0</VALUE> </RETURNVALUE> <PARAMVALUE NAME="Result" PARAMTYPE="string"> <VALUE>_testCMPIInstance </VALUE> hooks/post-receive -- SFCB - Small Footprint CIM Broker |