Hi Hung, Reviewed, but not tested. Ack from me.
Thanks, Zoran -----Original Message----- From: Hung Nguyen [mailto:hung.d.ngu...@dektech.com.au] Sent: den 18 oktober 2016 08:58 To: Zoran Milinkovic <zoran.milinko...@ericsson.com>; reddy.neelaka...@oracle.com Cc: opensaf-devel@lists.sourceforge.net Subject: [PATCH 1 of 1] immtool: print out enum name for SAF error code [#2123] osaf/tools/safimm/immcfg/imm_cfg.c | 26 ++++++++++---------- osaf/tools/safimm/immcfg/imm_import.cc | 41 +++++++++++++++++---------------- 2 files changed, 34 insertions(+), 33 deletions(-) Print out enum name for SAF error code. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -589,7 +589,7 @@ int object_create(const SaNameT **object "(see: immcfg -h under '--unsafe')\n"); } if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } } @@ -737,7 +737,7 @@ int object_modify(const SaNameT **object "(see: immcfg -h under '--unsafe')\n"); } if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } } goto done; @@ -809,7 +809,7 @@ int object_delete(const SaNameT **object "(see: immcfg -h under '--unsafe')\n"); } if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } } @@ -904,7 +904,7 @@ static int class_change(SaImmHandleT imm * and in that case, the schema change is enabled by default (isSchemaChangeEnabled = 2) */ if((error = immutil_saImmOmAccessorInitialize(immHandle, &accessorHandle)) != SA_AIS_OK) { - fprintf(stderr, "Failed to initialize accessor handle. Error: %d\n", error); + fprintf(stderr, "Failed to initialize accessor handle. Error: %s\n", saf_error(error)); return EXIT_FAILURE; } @@ -916,7 +916,7 @@ static int class_change(SaImmHandleT imm /* Check for the existence of attributes */ if((error = immutil_saImmOmClassDescriptionGet_2(immHandle, className, &classCategory, &attrDefinitions)) != SA_AIS_OK) { - fprintf(stderr, "Cannot get class definition for '%s'. Error: %d\n", className, error); + fprintf(stderr, "Cannot get class definition for '%s'. Error: %s\n", className, saf_error(error)); return EXIT_FAILURE; } @@ -972,7 +972,7 @@ static int class_change(SaImmHandleT imm } if((error = immutil_saImmOmAdminOperationInvoke_2(ownerHandle1, &opensafImmObjectName, 1, 1, params, &err, SA_TIME_ONE_SECOND * 60)) != SA_AIS_OK) { - fprintf(stderr, "Failed to enable schema changes. Error: %d\n", error); + fprintf(stderr, "Failed to enable schema changes. Error: %s\n", saf_error(error)); rc = EXIT_FAILURE; goto done; } @@ -981,12 +981,12 @@ static int class_change(SaImmHandleT imm if((error = immutil_saImmOmClassCreate_2(immHandle, className, classCategory, (const SaImmAttrDefinitionT_2 **)attrDefinitions)) != SA_AIS_OK) { rc = EXIT_FAILURE; if(isSchemaChangeEnabled == 2) - fprintf(stderr, "Cannot change the class. Probable cause is that PBE is disabled. Try to turn on schema changes manually. Error: %d\n", error); + fprintf(stderr, "Cannot change the class. Probable cause is that PBE is disabled. Try to turn on schema changes manually. Error: %s\n", saf_error(error)); else { if(error == SA_AIS_ERR_EXIST) - fprintf(stderr, "No change in the class. Error: %d\n", error); + fprintf(stderr, "No change in the class. Error: %s\n", saf_error(error)); else - fprintf(stderr, "Failed to change the class flags. Error: %d\n", error); + fprintf(stderr, "Failed to change the class flags. Error: %s\n", saf_error(error)); } } @@ -997,7 +997,7 @@ static int class_change(SaImmHandleT imm const SaImmAdminOperationParamsT_2 *params[2] = { ¶m, NULL }; if((error = immutil_saImmOmAdminOperationInvoke_2(ownerHandle1, &opensafImmObjectName, 0, 2, params, &err, SA_TIME_ONE_SECOND * 60)) != SA_AIS_OK) { - fprintf(stderr, "Failed to disable schema changes. Error: %d\n", error); + fprintf(stderr, "Failed to disable schema changes. Error: %s\n", saf_error(error)); rc = EXIT_FAILURE; } } @@ -1037,7 +1037,7 @@ static int ccb_apply() { ++ix; } } else if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } rc = EXIT_FAILURE; @@ -1107,7 +1107,7 @@ static int ccb_validate() { ++ix; } } else if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } } } @@ -1691,7 +1691,7 @@ static int imm_operation(int argc, char ++ix; } } else if(rc2 != SA_AIS_OK) { - fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %d\n", rc2); + fprintf(stderr, "saImmOmCcbGetErrorStrings failed: %s\n", saf_error(rc2)); } rc = EXIT_FAILURE; diff --git a/osaf/tools/safimm/immcfg/imm_import.cc b/osaf/tools/safimm/immcfg/imm_import.cc --- a/osaf/tools/safimm/immcfg/imm_import.cc +++ b/osaf/tools/safimm/immcfg/imm_import.cc @@ -36,6 +36,7 @@ #include <saAis.h> #include <saImmOm.h> #include <immutil.h> +#include <saf_error.h> #include "osaf_extended_name.h" @@ -533,12 +534,12 @@ void setAdminOwnerHelper(ParserState* st if(!state->validation) { LOG_IN(" Calling saImmOmAdminOwnerSet on parent '%s'", tmpStr); - int errorCode = immutil_saImmOmAdminOwnerSet(state->ownerHandle, + SaAisErrorT errorCode = immutil_saImmOmAdminOwnerSet(state->ownerHandle, (const SaNameT**) objectNames, SA_IMM_ONE); if (SA_AIS_OK != errorCode) { - LOG_ER("Failed to call saImmOmAdminOwnerSet on parent: '%s' , rc = %d", tmpStr, errorCode); + LOG_ER("Failed to call saImmOmAdminOwnerSet on parent: '%s' , rc = %s", tmpStr, saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; return; @@ -763,7 +764,7 @@ static void createImmObject(ParserState* errorCode = immutil_saImmOmAccessorInitialize(state->immHandle, &accessorHandle); if (SA_AIS_OK != errorCode) { - fprintf(stderr, "FAILED: saImmOmAccessorInitialize failed: %d\n", errorCode); + fprintf(stderr, "FAILED: saImmOmAccessorInitialize failed: %s\n", saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; goto done; @@ -773,7 +774,7 @@ static void createImmObject(ParserState* NULL, // get all attributes &existing_attributes); if (SA_AIS_OK != errorCode) { - fprintf(stderr, "FAILED: saImmOmAccessorGet_2 failed: %d\n", errorCode); + fprintf(stderr, "FAILED: saImmOmAccessorGet_2 failed: %s\n", saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; goto done; @@ -806,14 +807,14 @@ static void createImmObject(ParserState* errorCode = immutil_saImmOmAccessorFinalize(accessorHandle); if (SA_AIS_OK != errorCode) { - fprintf(stderr, "FAILED: saImmOmAccessorFinalize failed: %d\n", errorCode); + fprintf(stderr, "FAILED: saImmOmAccessorFinalize failed: %s\n", saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; } } else { - fprintf(stderr, "FAILED to create object of class '%s', rc = %d\n", - className, errorCode); + fprintf(stderr, "FAILED to create object of class '%s', rc = %s\n", + className, saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; } @@ -1063,8 +1064,8 @@ static void createImmClass(ParserState* &existing_classCategory, &existing_attrDefinitions); if (SA_AIS_OK != errorCode) { - fprintf(stderr, "FAILED to get IMM class description for '%s', rc = %d\n", - className, errorCode); + fprintf(stderr, "FAILED to get IMM class description for '%s', rc = %s\n", + className, saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; } else { @@ -1111,7 +1112,7 @@ static void createImmClass(ParserState* existing_attrDefinitions); } } else { - fprintf(stderr, "FAILED to create class '%s', rc = %d\n", className, errorCode); + fprintf(stderr, "FAILED to create class '%s', rc = %s\n", className, saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; } @@ -1687,8 +1688,8 @@ static void endElementHandler(void* user SA_TRUE, &state->ownerHandle); if (errorCode != SA_AIS_OK) { - LOG_ER("Failed on saImmOmAdminOwnerInitialize %d", - errorCode); + LOG_ER("Failed on saImmOmAdminOwnerInitialize %s", + saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; return; @@ -1700,7 +1701,7 @@ static void endElementHandler(void* user imm_import_ccb_safe?(SA_IMM_CCB_REGISTERED_OI|SA_IMM_CCB_ALLOW_NULL_OI):0x0, &state->ccbHandle); if (errorCode != SA_AIS_OK) { - LOG_ER("Failed to initialize ImmOmCcb %d", errorCode); + LOG_ER("Failed to initialize ImmOmCcb %s", saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; return; @@ -1720,7 +1721,7 @@ static void endElementHandler(void* user if (state->ccbInit) { errorCode = immutil_saImmOmCcbApply(state->ccbHandle); if (SA_AIS_OK != errorCode) { - LOG_ER("Failed to apply object creations %d", errorCode); + LOG_ER("Failed to apply object creations %s", saf_error(errorCode)); stopParser(state); state->parsingStatus = 1; return; @@ -2612,14 +2613,14 @@ int loadImmXML(const char *xmlfile, int if(!transaction_mode) { errorCode = immutil_saImmOmInitialize(&(state.immHandle), NULL, &version); if (SA_AIS_OK != errorCode) { - LOG_ER("Failed to initialize the IMM OM interface (%d)", errorCode); + LOG_ER("Failed to initialize the IMM OM interface (%s)", saf_error(errorCode)); return 1; } } else { if(!(*imm_import_immHandle)) { errorCode = immutil_saImmOmInitialize(&state.immHandle, NULL, &version); if (SA_AIS_OK != errorCode) { - fprintf(stderr, "Failed to initialize the IMM OM interface (%d)\n", errorCode); + fprintf(stderr, "Failed to initialize the IMM OM interface (%s)\n", saf_error(errorCode)); return 1; } } else @@ -2686,8 +2687,8 @@ int loadImmXML(const char *xmlfile, int if (state.ccbInit) { errorCode = immutil_saImmOmCcbFinalize(state.ccbHandle); if (SA_AIS_OK != errorCode) { - LOG_WA("Failed to finalize the ccb object connection %d", - errorCode); + LOG_WA("Failed to finalize the ccb object connection %s", + saf_error(errorCode)); } } @@ -2695,7 +2696,7 @@ int loadImmXML(const char *xmlfile, int if (state.adminInit) { errorCode = immutil_saImmOmAdminOwnerFinalize(state.ownerHandle); if (SA_AIS_OK != errorCode) { - LOG_WA("Failed on saImmOmAdminOwnerFinalize (%d)", errorCode); + LOG_WA("Failed on saImmOmAdminOwnerFinalize (%s)", saf_error(errorCode)); } } @@ -2703,7 +2704,7 @@ int loadImmXML(const char *xmlfile, int if (state.immInit) { errorCode = immutil_saImmOmFinalize(state.immHandle); if (SA_AIS_OK != errorCode) { - LOG_WA("Failed on saImmOmFinalize (%d)", errorCode); + LOG_WA("Failed on saImmOmFinalize (%s)", saf_error(errorCode)); } } } else { ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel