 len = 34 + strlen(op->user_data?op->user_data:"-1"); crm_malloc0(fail_state, sizeof(char)*(len+1)); if(fail_state != NULL) { snprintf(fail_state, len, "%s:%d", op->user_data?op->user_data:"-1", op->op_status); 
 if(op->user_data == NULL) { op->user_data = generate_transition_key(-1, fsa_our_uname); 
build_operation_update(	crm_data_t *xml_rsc, lrm_op_t *op, const char *src, int lpc){	int len = 0;	char *tmp = NULL;	char *fail_state = NULL;	const char *state = NULL;	crm_data_t *xml_op = NULL;	char *op_id = NULL;	CRM_DEV_ASSERT(op != NULL);	if(crm_assert_failed) {		return FALSE;	}	crm_debug("%s: Updating resouce %s after %s %s op",		 src, op->rsc_id, op_status2text(op->op_status), op->op_type);	if(op->op_status == LRM_OP_CANCELLED) {		crm_debug("Ignoring cancelled op");		return TRUE;	}		xml_op = create_xml_node(xml_rsc, XML_LRM_TAG_RSC_OP);		op_id = generate_op_key(op->rsc_id, op->op_type, op->interval);	crm_xml_add(xml_op, XML_ATTR_ID, op_id);	crm_free(op_id);	crm_xml_add(xml_rsc, XML_LRM_ATTR_LASTOP, op->op_type);	crm_xml_add(xml_op,  XML_LRM_ATTR_TASK,   op->op_type);	crm_xml_add(xml_op,  "origin", src);		/* Handle recurring ops - infer last op_status */	if(op->op_status == LRM_OP_PENDING && op->interval > 0) {		if(op->rc == 0) {			crm_debug("Mapping pending operation to DONE");			op->op_status = LRM_OP_DONE;		} else {			crm_debug("Mapping pending operation to ERROR");			op->op_status = LRM_OP_ERROR;		}	}		len = 34 + strlen(op->user_data?op->user_data:"-1");	crm_malloc0(fail_state, sizeof(char)*(len+1));	if(fail_state != NULL) {		snprintf(fail_state, len, "%s:%d",			 op->user_data?op->user_data:"-1", op->op_status);	}	crm_xml_add(xml_op,  "transition_magic", fail_state);	crm_free(fail_state);			switch(op->op_status) {		case LRM_OP_PENDING:			break;		case LRM_OP_CANCELLED:			crm_err("What to do here");			break;		case LRM_OP_ERROR:		case LRM_OP_TIMEOUT:		case LRM_OP_NOTSUPPORTED:			crm_debug("Resource action %s/%s failed: %d",				  op->rsc_id, op->op_type, op->op_status);			len = strlen(op->op_type);			len += strlen("_failed_");			crm_malloc0(fail_state, sizeof(char)*len);			if(fail_state != NULL) {				sprintf(fail_state, "%s_failed", op->op_type);			}			crm_xml_add(xml_op, XML_LRM_ATTR_RSCSTATE, fail_state);			crm_xml_add(xml_rsc, XML_LRM_ATTR_RSCSTATE, fail_state);			crm_free(fail_state);						break;		case LRM_OP_DONE:			if(safe_str_eq(CRMD_ACTION_START, op->op_type)) {				state = CRMD_ACTION_STARTED;			} else if(safe_str_eq(CRMD_ACTION_STOP, op->op_type)) {				state = CRMD_ACTION_STOPPED;							} else if(safe_str_eq(CRMD_ACTION_MON, op->op_type)) {				state = CRMD_ACTION_STARTED;					} else {				crm_warn("Using status \"%s\" for op \"%s\""					 "... this is still in the experimental stage.",					 CRMD_ACTION_GENERIC_OK, op->op_type);				state = CRMD_ACTION_GENERIC_OK;			}				crm_xml_add(xml_op, XML_LRM_ATTR_RSCSTATE, state);			crm_xml_add(xml_rsc, XML_LRM_ATTR_RSCSTATE, state);			break;	}		tmp = crm_itoa(op->call_id);	crm_xml_add(xml_op,  XML_LRM_ATTR_CALLID, tmp);	crm_free(tmp);	/* set these on 'xml_rsc' too to make life easy for the TE */	tmp = crm_itoa(op->rc);	crm_xml_add(xml_op, XML_LRM_ATTR_RC, tmp);	crm_xml_add(xml_rsc, XML_LRM_ATTR_RC, tmp);	crm_free(tmp);	tmp = crm_itoa(op->op_status);	crm_xml_add(xml_op, XML_LRM_ATTR_OPSTATUS, tmp);	crm_xml_add(xml_rsc, XML_LRM_ATTR_OPSTATUS, tmp);	crm_free(tmp);	set_node_tstamp(xml_op);		return TRUE;}
8182	/local/tlutelli/issta_data/temp/c/2005_temp/2005/8182/bf94f7dc9183bc3d0254f625988b696e18664f40/lrm.c/buggy/crm/crmd/lrm.c