Hi Thien,
See my comments inline.
Regards, Vu
On 9/3/19 2:23 PM, thien.m.huynh wrote:
---
src/imm/tools/imm_dumper.cc | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/imm/tools/imm_dumper.cc b/src/imm/tools/imm_dumper.cc
index 68071f1..a8b45a5 100644
--- a/src/imm/tools/imm_dumper.cc
+++ b/src/imm/tools/imm_dumper.cc
@@ -392,6 +392,7 @@ static std::map<std::string, std::string> cacheRDNs(
std::list<std::string> classNamesList;
SaImmClassCategoryT classCategory;
SaImmAttrDefinitionT_2** attrs;
+ SaAisErrorT errorCode;
[Vu] Move this into the below 'while' loop.
std::map<std::string, std::string> classRDNMap;
if (selectedClassList.empty()) {
@@ -403,19 +404,22 @@ static std::map<std::string, std::string> cacheRDNs(
std::list<std::string>::iterator it = classNamesList.begin();
while (it != classNamesList.end()) {
- saImmOmClassDescriptionGet_2(immHandle, (char*)it->c_str(), &classCategory,
- &attrs);
-
- for (SaImmAttrDefinitionT_2** p = attrs; *p != NULL; p++) {
- if ((*p)->attrFlags & SA_IMM_ATTR_RDN) {
- classRDNMap[*it] = std::string((*p)->attrName);
- break;
+ errorCode = saImmOmClassDescriptionGet_2(immHandle, (char*)it->c_str(),
+ &classCategory, &attrs);
+ if (errorCode != SA_AIS_OK) {
+ std::cerr << "Failed to get the description for " << it->c_str()
+ << " class - exiting, " << errorCode << std::endl;
+ exit(1);
[Vu]
- Narrow down the scope of above `errorCode`.
- Use '*it' instead of 'it->c_str()'
- Use `exit(EXIT_FAILURE)` instead of `exit(1)
- Remove 'else' statement.
e.g:
SaAisCode error_code = saImmOmClassDescriptionGet_(...);
if (error_code != SA_AIS_OK) {
std::cerr << "Failed to get the description of " << *it << "
class: "
<< errorCode << " - exiting!" << std.endl;
exit(EXIT_FAILURE);
}
+ } else {
+ for (SaImmAttrDefinitionT_2** p = attrs; *p != NULL; p++) {
+ if ((*p)->attrFlags & SA_IMM_ATTR_RDN) {
+ classRDNMap[*it] = std::string((*p)->attrName);
+ break;
+ }
}
+ /* Avoid memory leaking */
+ saImmOmClassDescriptionMemoryFree_2(immHandle, attrs);
}
-
- /* Avoid memory leaking */
- saImmOmClassDescriptionMemoryFree_2(immHandle, attrs);
-
++it;
}
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel