crm_debug_4("Freeing saved CIB %p", saved_cib);
crm_debug_2("Changes activated"); log_xml_diff(LOG_DEBUG, diff, __FUNCTION__);
activateCibXml(crm_data_t *new_cib, const char *filename){	int error_code = cib_ok;	crm_data_t *saved_cib = get_the_CIB();	const char *filename_bak = CIB_BACKUP; /* calculate */	crm_log_xml_debug_3(new_cib, "Attempting to activate CIB");	CRM_ASSERT(new_cib != saved_cib);	crm_validate_data(new_cib);	if(saved_cib != NULL) {		crm_validate_data(saved_cib);	}		if (initializeCib(new_cib) == FALSE) {		crm_warn("Ignoring invalid or NULL Cib");		error_code = -5;	} else if(cib_writes_enabled) {		if(saved_cib != NULL) {			CRM_DEV_ASSERT(0 >= moveFile(filename,						     filename_bak,						     FALSE, NULL));						if (crm_assert_failed) {				crm_warn("Could not make backup of the current"					 " Cib... aborting update.");				error_code = -1;			}		}				if(error_code == cib_ok) {			crm_debug_3("Writing CIB out to %s", CIB_FILENAME);			CRM_DEV_ASSERT(write_xml_file(					       new_cib, CIB_FILENAME) >= 0);			if (crm_assert_failed) {				error_code = -4;			}		}		if(error_code == -4 && saved_cib != NULL) {			CRM_DEV_ASSERT(moveFile(filename_bak,						filename, FALSE, NULL) >= 0);			if (crm_assert_failed){				crm_crit("Could not restore the backup of the "					 " current Cib... panic!");				error_code = -2;				/* should probably exit here  */			}		}		CRM_DEV_ASSERT(saved_cib != NULL || error_code == cib_ok);		if(crm_assert_failed) {			/* oh we are so dead  */			crm_crit("Could not write out new CIB and no saved"				 " version to revert to");				error_code = -3;					} else if(error_code != cib_ok) {			crm_crit("Update of Cib failed (%d)... reverting"				 " to last known valid version",				 error_code);			CRM_DEV_ASSERT(initializeCib(saved_cib));			if (crm_assert_failed) {				/* oh we are so dead  */				crm_crit("Could not re-initialize with the old"					 " CIB.  Can anyone say corruption?");				error_code = -3;			}		}	}	/* Make sure memory is cleaned up appropriately */	if (error_code != cib_ok) {		crm_debug_4("Freeing new CIB %p", new_cib);		free_xml(new_cib);			} else if(saved_cib != NULL) {		crm_debug_4("Freeing saved CIB %p", saved_cib);		crm_validate_data(saved_cib);		free_xml(saved_cib);	}	return error_code;    }