本文整理汇总了C++中RW_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ RW_ASSERT函数的具体用法?C++ RW_ASSERT怎么用?C++ RW_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RW_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rwdts_appconf_prepare_complete_fail
void rwdts_appconf_prepare_complete_fail(rwdts_appconf_t *ac,
const rwdts_xact_info_t *xact_info,
rw_status_t rs,
const char *errstr) {
RW_ASSERT_TYPE(ac, rwdts_appconf_t);
rwdts_appconf_xact_t *appx =
(rwdts_appconf_xact_t *)xact_info->xact->group[ac->group->id]->scratch;
RW_ASSERT_TYPE(appx, rwdts_appconf_xact_t);
RW_ASSERT(appx->queries_in > 0);
appx->queries_out++;
RW_ASSERT(appx->queries_out <= appx->queries_in);
int idx = appx->errs_ct++;
appx->errs = realloc(appx->errs, sizeof(appx->errs[0]) * appx->errs_ct);
appx->errs[idx].str = strdup(errstr);
appx->errs[idx].rs = rs;
appx->errs[idx].corrid = (xact_info->queryh &&
((RWDtsQuery*)xact_info->queryh)->has_corrid ?
((RWDtsQuery*)xact_info->queryh)->corrid : 0);
rwdts_member_send_error(xact_info->xact, NULL,
(RWDtsQuery*)xact_info->queryh,
NULL, NULL, rs, errstr);
RWTRACE_CRIT(xact_info->apih->rwtrace_instance,
RWTRACE_CATEGORY_RWTASKLET,
"APPCONF prepare_complete_fail code %d str '%s'\n",
rs,
errstr);
rwdts_xact_info_respond_keyspec(xact_info, RWDTS_XACT_RSP_CODE_NACK,
NULL, NULL);
}
示例2: get_dompath
bool
KeySpecHelper::is_rooted()
{
const ProtobufCMessage *dom_path = get_dompath();
if (!dom_path) {
return false;
}
size_t offset;
protobuf_c_boolean is_dptr = FALSE;
void *field_ptr = nullptr;
const ProtobufCFieldDescriptor *fd = nullptr;
size_t count = protobuf_c_message_get_field_desc_count_and_offset(dom_path,
RW_SCHEMA_TAG_KEYSPEC_ROOTED, &fd, &field_ptr, &offset, &is_dptr);
if (!count) {
return false;
}
RW_ASSERT(fd->type == PROTOBUF_C_TYPE_BOOL);
RW_ASSERT(fd->label != PROTOBUF_C_LABEL_REPEATED);
if (*(protobuf_c_boolean *)field_ptr) {
return true;
}
return false;
}
示例3: rw_ip_prefix_t_get_str
char* rw_ip_prefix_t_get_str(char* str, const rw_ip_prefix_t *prefix)
{
char maskstr[5];
RW_ASSERT(prefix);
RW_ASSERT((prefix->ip_v == RW_IPV6) || (prefix->ip_v == RW_IPV4));
if (prefix->ip_v == RW_IPV6) {
struct in6_addr in6;
int i;
for (i = 0; i < 4; i++){
in6.s6_addr32[i] = htonl(prefix->u.v6.addr[i]);
}
inet_ntop(AF_INET6, &(in6), str, INET6_ADDRSTRLEN);
} else { // RW_IPV4
struct in_addr in;
in.s_addr = htonl(prefix->u.v4.addr);
inet_ntop(AF_INET, &(in), str, INET6_ADDRSTRLEN);
}
sprintf(maskstr, "/%d", prefix->masklen);
strcat(str, maskstr);
return str;
}
示例4: rw_ip_addr_cmp
int rw_ip_addr_cmp(const void *v1, const void *v2)
{
const rw_ip_addr_t *a1 = (const rw_ip_addr_t *)v1;
const rw_ip_addr_t *a2 = (const rw_ip_addr_t *)v2;
RW_ASSERT((a1->ip_v == RW_IPV4) ||
(a1->ip_v == RW_IPV6));
RW_ASSERT((a2->ip_v == RW_IPV4) ||
(a2->ip_v == RW_IPV6));
if (a1->ip_v < a2->ip_v)
return -1;
if (a1->ip_v > a2->ip_v)
return 1;
if (a1->ip_v == RW_IPV4){
if (a1->u.v4.addr < a2->u.v4.addr)
return -1;
if (a1->u.v4.addr > a2->u.v4.addr)
return 1;
}else{
int i;
for (i = 0; i < 4; i++){
if (a1->u.v6.addr[i] < a2->u.v6.addr[i])
return -1;
if (a1->u.v6.addr[i] > a2->u.v6.addr[i])
return 1;
}
}
return 0;
}
示例5: rwlogd_file_send_log
static void
rwlogd_file_send_log(RwlogdPeerAPI_Service *srv,
const RwlogdFileSendLogReq *req,
void *user_handle,
RwlogdFileSendLogRsp_Closure closure,
void *closure_data)
{
rwlogd_instance_ptr_t instance;
RwlogdFileSendLogRsp rsp;
// Validate input parameters
RW_ASSERT(srv);
if (!srv) { return; }
RW_ASSERT(req);
if (!req) { return; }
RW_ASSERT(user_handle);
if (!user_handle) { return; }
RW_ASSERT(closure);
if (!closure) { return; }
RW_ASSERT(closure_data);
if (!closure_data) { return; }
instance = (rwlogd_instance_ptr_t) user_handle;
//RW_CF_TYPE_VALIDATE(instance, rwlogd_instance_ptr_t);
rwlogd_handle_file_log(instance->rwlogd_info, req->my_key,req->sink_name);
// Initialize response structure
rwlogd_file_send_log_rsp__init(&rsp);
closure(&rsp, closure_data);
return;
}
示例6: rwlogd_send_log
static void
rwlogd_send_log(RwlogdPeerAPI_Service *srv,
const RwlogdSendLogReq *req,
void *user_handle,
RwlogdStatus_Closure closure,
void *closure_data)
{
rwlogd_instance_ptr_t instance;
RwlogdStatus rsp;
size_t log_size = 0;
size_t offset = 0;
// Validate input parameters
RW_ASSERT(srv);
if (!srv) { return; }
RW_ASSERT(req);
if (!req) { return; }
RW_ASSERT(user_handle);
if (!user_handle) { return; }
RW_ASSERT(closure);
if (!closure) { return; }
RW_ASSERT(closure_data);
if (!closure_data) { return; }
instance = (rwlogd_instance_ptr_t) user_handle;
//RW_CF_TYPE_VALIDATE(instance, rwlogd_instance_ptr_t);
RWLOG_DEBUG_PRINT("Received Log in instance: %d of length %lu\n", instance->rwtasklet_info->identity.rwtasklet_instance_id,req->log_msg.len);
instance->rwlogd_info->stats.peer_recv_requests++;
while(offset < req->log_msg.len)
{
rwlog_hdr_t *hdr = (rwlog_hdr_t *)(req->log_msg.data + offset);
if(hdr->magic != RWLOG_MAGIC || ((offset + hdr->size_of_proto+sizeof(rwlog_hdr_t)) > req->log_msg.len) ||
(hdr->log_category > instance->rwlogd_info->num_categories || hdr->log_severity > RW_LOG_LOG_SEVERITY_DEBUG)) {
RWLOG_DEBUG_PRINT("read %dl Magic%d category:%u Severity:%u; rotating\n",
(int)req->log_msg.len, hdr->magic,hdr->log_category,hdr->log_severity);
instance->rwlogd_info->stats.invalid_log_from_peer++;
rwlogd_status__init(&rsp);
rsp.status = RWLOGD_STATUS__MSGSTATUS__FAILURE;
closure(&rsp, closure_data);
return;
}
log_size = hdr->size_of_proto+sizeof(rwlog_hdr_t);
offset += log_size;
rwlogd_handle_log(instance,(uint8_t *)hdr,log_size,TRUE);
instance->rwlogd_info->stats.logs_received_from_peer++;
}
// Initialize response structure
rwlogd_status__init(&rsp);
rsp.status = RWLOGD_STATUS__MSGSTATUS__SUCCESS;
closure(&rsp, closure_data);
return;
}
示例7: build_and_move_iterator_child_value
// Copiers for Confd TLV List Iterators
rw_tree_walker_status_t build_and_move_iterator_child_value (RwTLVListIterator* parent_iter,
RwPbcmTreeIterator* child_iter)
{
rw_ylib_data_t child_val;
rw_status_t rs = child_iter->get_value(&child_val);
RW_ASSERT(RW_STATUS_SUCCESS == rs);
RwTLVListIterator::tlv_list_iter_t parent,child;
rs = parent_iter->get_value(parent);
if (rs != RW_STATUS_SUCCESS) {
return RW_TREE_WALKER_FAILURE;
}
// Adding a child needs zero (leaf list with existing confd TLV), one
// (leaf with no existing confd TLV) or two (containers and lists) confd
// TLV value
rw_tree_walker_status_t rt = RW_TREE_WALKER_FAILURE;
RW_ASSERT(RW_YLIB_DATA_TYPE_PB == child_val.type);
rt = add_tlv_list_child (parent_iter, &child_val.rw_pb,
child_iter->get_yang_node_name(),
child_iter->get_yang_ns(),
child);
if (rt != RW_TREE_WALKER_SUCCESS) {
// no need to move to a child
return rt;
}
rs = parent_iter->move_to_child (child);
RW_ASSERT(RW_STATUS_SUCCESS == rs);
return rt;
}
示例8: get_string_value
rw_status_t get_string_value (rw_confd_value_t *v,
std::string& str)
{
str.clear();
if (v->value) {
if (v->cs_node->info.type) {
char value[1024];
struct confd_type *ct = v->cs_node->info.type;
if (C_LIST == v->cs_node->info.shallow_type) {
ct = confd_get_leaf_list_type (v->cs_node);
RW_ASSERT(ct);
}
int len = confd_val2str (ct, v->value,value, sizeof (value));
if (len < 0) {
return RW_STATUS_FAILURE;
}
RW_ASSERT ((size_t) len < sizeof (value));
str = value;
} else {
str = confd_hash2str(v->cs_node->tag);
}
}
return RW_STATUS_SUCCESS;
}
示例9: rwdts_kv_update_db_xact_commit
rw_status_t
rwdts_kv_update_db_xact_commit(rwdts_member_data_object_t *mobj, RWDtsQueryAction action)
{
rwdts_api_t *apih;
rwdts_member_registration_t *reg;
reg = mobj->reg;
RW_ASSERT_TYPE(reg, rwdts_member_registration_t);
RW_ASSERT(action != RWDTS_QUERY_INVALID);
apih = reg->apih;
RW_ASSERT(apih);
if (mobj->kv_tab_handle == NULL) {
/* Problem */
return RW_STATUS_FAILURE;
}
RWDTS_CREATE_SHARD(reg->reg_id, apih->client_path, apih->router_path);
/* Perform KV xact operation */
if (apih->db_up && ((action == RWDTS_QUERY_CREATE) ||
(RWDTS_QUERY_UPDATE == action))) {
rwdts_kv_light_api_xact_insert_commit(mobj->kv_tab_handle, mobj->serial_num,
shard, (void *)mobj->key,
mobj->key_len, (void *)rwdts_kv_light_insert_xact_commit_obj_cb,
(void *)mobj);
} else if (apih->db_up && (action == RWDTS_QUERY_DELETE)) {
rwdts_kv_light_table_xact_delete_commit(mobj->kv_tab_handle, mobj->serial_num,
(void *)mobj->key,
mobj->key_len,
(void *)rwdts_kv_light_delete_xact_commit_obj_cb,
(void *)mobj);
}
return RW_STATUS_SUCCESS;
}
示例10: rw_ip_prefix_t_unpack
static protobuf_c_boolean rw_ip_prefix_t_unpack(
ProtobufCInstance *instance,
const ProtobufCCTypeDescriptor* ctypedesc,
const ProtobufCFieldDescriptor* fielddesc,
size_t in_size,
const uint8_t* in,
protobuf_c_boolean maybe_clear,
void* void_member)
{
UNUSED(fielddesc);
RW_ASSERT(ctypedesc == &rw_ip_prefix_t_helper);
RW_ASSERT(void_member);
RW_ASSERT(in);
RW_ASSERT(instance);
rw_ip_prefix_t* ip_prefaddr = (rw_ip_prefix_t*)void_member;
char str[RW_PREFIX_ADDRSTRLEN*2];
if (in_size >= sizeof(str)) {
return FALSE;
}
memcpy(str, in, in_size);
str[in_size] = 0;
memset(ip_prefaddr, 0, sizeof(*ip_prefaddr));
char* slash = strchr(str, '/');
if (slash){
*slash = 0;
}
// Check if this is an IPv6 address
if (strchr(str, ':')) {
struct in6_addr in6;
int i;
ip_prefaddr->ip_v = RW_IPV6;
if (inet_pton(AF_INET6, str, &(in6)) <= 0) {
return FALSE;
}
for (i = 0; i < 4; i++){
ip_prefaddr->u.v6.addr[i] = ntohl(in6.s6_addr32[i]);
}
} else {
struct in_addr in;
// Assume IPv4 address
ip_prefaddr->ip_v = RW_IPV4;
if (inet_aton(str, (&in)) <= 0){
return FALSE;
}
ip_prefaddr->u.v4.addr = ntohl(in.s_addr);
}
if (slash){
char *end = NULL;
unsigned long res = strtoul(slash+1, &end, 0);
if (end && *end != '\0') {
return FALSE;
}
ip_prefaddr->masklen = (uint8_t)res;
}
return TRUE;
}
示例11: rwmsgbroker__component__instance_start
static void
rwmsgbroker__component__instance_start(RwTaskletPluginComponent *self,
RwTaskletPluginComponentHandle *h_component,
RwTaskletPluginInstanceHandle *h_instance)
{
rwmsgbroker_component_ptr_t component;
rwmsgbroker_instance_ptr_t instance;
rwcal_module_ptr_t rwcal;
// Validate input parameters
component = (rwmsgbroker_component_ptr_t) h_component->priv;
RW_CF_TYPE_VALIDATE(component, rwmsgbroker_component_ptr_t);
instance = (rwmsgbroker_instance_ptr_t) h_instance->priv;
RW_CF_TYPE_VALIDATE(instance, rwmsgbroker_instance_ptr_t);
// The instance is started so print a debug message
RWTRACE_INFO(instance->rwtasklet_info->rwtrace_instance,
RWTRACE_CATEGORY_RWTASKLET,
"RW.MsgBroker -- Tasklet [%d] is started on VM [%d]!",
instance->rwtasklet_info->identity.rwtasklet_instance_id, //0);
instance->rwtasklet_info->rwvcs->identity.rwvm_instance_id);
rwvcs_instance_ptr_t rwvcs = instance->rwtasklet_info->rwvcs;
RW_ASSERT(rwvcs);
int rwvm_instance_id = rwvcs->identity.rwvm_instance_id;
RW_ASSERT(rwvcs->pb_rwmanifest
&& rwvcs->pb_rwmanifest->init_phase
&& rwvcs->pb_rwmanifest->init_phase->settings
&& rwvcs->pb_rwmanifest->init_phase->settings->rwmsg);
int multi_broker = (rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker &&
rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->has_enable &&
rwvcs->pb_rwmanifest->init_phase->settings->rwmsg->multi_broker->enable);
char *ext_ip_address = instance->rwtasklet_info->rwvcs->identity.vm_ip_address;
RWTRACE_INFO(instance->rwtasklet_info->rwtrace_instance,
RWTRACE_CATEGORY_RWTASKLET,
"RW.MsgBroker -- Tasklet [%d] is started on VM [%d] ip-addr [%s] multi_broker [%d]!\n",
instance->rwtasklet_info->identity.rwtasklet_instance_id,
rwvm_instance_id, ext_ip_address,
multi_broker);
int sid = 1;
rwcal = ((rwvx_instance_t*)(instance->rwtasklet_info->rwvx))->rwcal_module;
instance->broker = rwmsg_broker_create(sid,
(multi_broker?rwvm_instance_id:0),
ext_ip_address,
instance->rwtasklet_info->rwsched_instance,
instance->rwtasklet_info->rwsched_tasklet_info,
rwcal,
rwtasklet_info_is_collapse_thread(instance->rwtasklet_info), /* mainq */
instance->rwtasklet_info->rwmsg_endpoint,
instance->rwtasklet_info);
RW_ASSERT(instance->broker);
rw_status_t rs;
rs = rwmsg_broker_dts_registration (instance);
RW_ASSERT(rs == RW_STATUS_SUCCESS);
}
示例12: on_inventory_update
/*
* Called when we get a response from DTS with any additional component
* definitions added to the inventory via runtime configuration.
*
* Adds any new components to the manifest held by rwvcs and then schedules
* the init_phase.
*/
static void on_inventory_update(rwdts_xact_t * xact, rwdts_xact_status_t* xact_status, void * ud)
{
//rw_status_t status;
struct rwmain_gi * rwmain;
rwvcs_instance_ptr_t rwvcs;
vcs_manifest_inventory * ret_inventory;
vcs_manifest_inventory * inventory;
rwmain = (struct rwmain_gi *)ud;
rwvcs = rwmain->rwvx->rwvcs;
RW_CF_TYPE_VALIDATE(rwvcs, rwvcs_instance_ptr_t);
if (xact_status->status == RWDTS_XACT_FAILURE || xact_status->status == RWDTS_XACT_ABORTED) {
rwmain_trace_info(rwmain, "Lookup of component probably failed");
goto done;
}
rwmain_trace_info(rwmain, "Updating inventory");
rwdts_query_result_t *qrslt = rwdts_xact_query_result(xact, 0);
while (qrslt) {
ret_inventory = (vcs_manifest_inventory*)(qrslt->message);
RW_ASSERT(ret_inventory);
RW_ASSERT(ret_inventory->base.descriptor == RWPB_G_MSG_PBCMD(RwManifest_data_Manifest_Inventory));
inventory = rwvcs->pb_rwmanifest->inventory;
for (size_t i = 0; i < ret_inventory->n_component; ++i) {
// Any updates to the static manifest are going to be ignored.
if (rwvcs_manifest_have_component(rwvcs, ret_inventory->component[i]->component_name)) {
continue;
}
inventory->component = (vcs_manifest_component **)realloc(
inventory->component,
sizeof(vcs_manifest_component *) * (inventory->n_component + 1));
RW_ASSERT(inventory->component);
inventory->component[inventory->n_component] = (vcs_manifest_component*)protobuf_c_message_duplicate(
NULL,
&ret_inventory->component[i]->base,
ret_inventory->component[i]->base.descriptor);
inventory->n_component++;
rwmain_trace_info(
rwmain,
"Updating inventory with %s",
ret_inventory->component[i]->component_name);
}
qrslt = rwdts_xact_query_result(xact, 0);
}
done:
schedule_next(rwmain, init_phase, 0, NULL);
}
示例13: rw_sklist_comp_charbuf
/**
* Function to compare two character buffer keys of a SkipList
*/
int
rw_sklist_comp_charbuf(void * v1, void * v2)
{
const uint8_t *p1, *p2;
int32_t result;
RW_ASSERT(v1 != NULL);
RW_ASSERT(v2 != NULL);
p1 = (const uint8_t *)v1;
p2 = (const uint8_t *)v2;
result = (int32_t)*p1 - (int32_t)*p2;
return result?result:strcmp((const char *)p1,(const char *)p2); /* try to avoid strcmp */
}
示例14: rwdts_appconf_prepare_complete_na
void rwdts_appconf_prepare_complete_na(rwdts_appconf_t *ac,
const rwdts_xact_info_t *xact_info) {
RW_ASSERT_TYPE(ac, rwdts_appconf_t);
rwdts_appconf_xact_t *appx = (rwdts_appconf_xact_t *)xact_info->xact->group[ac->group->id]->scratch;
RW_ASSERT_TYPE(appx, rwdts_appconf_xact_t);
RW_ASSERT(appx->queries_in > 0);
appx->queries_out++;
RW_ASSERT(appx->queries_out <= appx->queries_in);
rwdts_xact_info_respond_keyspec(xact_info, RWDTS_XACT_RSP_CODE_NA, NULL, NULL);
}
示例15: process_init_phase
rw_status_t process_init_phase(struct rwmain_gi * rwmain)
{
rw_status_t status;
rwvcs_instance_ptr_t rwvcs;
rwvcs = rwmain->rwvx->rwvcs;
if (rwvcs->pb_rwmanifest->init_phase->settings->rwvcs->no_autostart == false) {
vcs_manifest_component *m_component;
char * instance_name = NULL;
instance_name = to_instance_name(rwmain->component_name, rwmain->instance_id);
RW_ASSERT(*instance_name);
// Lookup the component to start
status = rwvcs_manifest_component_lookup(rwvcs, rwmain->component_name, &m_component);
rwmain_trace_info(rwmain, "rwvcs_manifest_component_lookup %s", rwmain->component_name);
RW_ASSERT(status == RW_STATUS_SUCCESS);
if (m_component->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWVM) {
RWVCS_LATENCY_CHK_PRE(rwmain->rwvx->rwsched);
rwmain_rwvm_init(
rwmain,
m_component->rwvm,
rwmain->component_name,
rwmain->instance_id,
instance_name,
rwmain->parent_id);
RWVCS_LATENCY_CHK_POST(rwmain->rwvx->rwtrace, RWTRACE_CATEGORY_RWMAIN,
rwmain_rwvm_init, "rwmain_rwvm_init:%s", instance_name);
} else if (m_component->component_type == RWVCS_TYPES_COMPONENT_TYPE_RWPROC) {
RWVCS_LATENCY_CHK_PRE(rwmain->rwvx->rwsched);
rwmain_rwproc_init(
rwmain,
m_component->rwproc,
rwmain->component_name,
rwmain->instance_id,
instance_name,
rwmain->parent_id);
RWVCS_LATENCY_CHK_POST(rwmain->rwvx->rwtrace, RWTRACE_CATEGORY_RWMAIN,
rwmain_rwproc_init, "rwmain_rwproc_init:%s", instance_name);
} else {
rwmain_trace_crit(
rwmain,
"rwmain cannot start a component which is not a vm or process (%s)",
m_component->component_name);
RW_CRASH();
}
}
return RW_STATUS_SUCCESS;
}