本文整理匯總了C++中BAIL_ON_ERROR函數的典型用法代碼示例。如果您正苦於以下問題:C++ BAIL_ON_ERROR函數的具體用法?C++ BAIL_ON_ERROR怎麽用?C++ BAIL_ON_ERROR使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BAIL_ON_ERROR函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: sr_Over
void sr_Over(cpu_t *pcpu, decode_t *pdecoded) {
uint32_t tmp1 = pop(pcpu);
uint32_t tmp2 = pop(pcpu);
BAIL_ON_ERROR();
push(pcpu, tmp2);
push(pcpu, tmp1);
push(pcpu, tmp2);
}
示例2: lwmsg_peer_task_run_connect
static
LWMsgStatus
lwmsg_peer_task_run_connect(
LWMsgPeer* peer,
PeerAssocTask* task,
LWMsgTaskTrigger trigger,
LWMsgTaskTrigger* next_trigger,
LWMsgTime* next_timeout
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
status = lwmsg_assoc_connect(task->assoc, (LWMsgSession*) task->session);
switch (status)
{
case LWMSG_STATUS_SUCCESS:
task->type = PEER_TASK_DISPATCH;
BAIL_ON_ERROR(status = lwmsg_peer_log_connect(task));
/* Set up the fd the assoc just created for events */
BAIL_ON_ERROR(status = lwmsg_task_set_trigger_fd(task->event_task, CONNECTION_PRIVATE(task->assoc)->fd));
break;
case LWMSG_STATUS_PENDING:
task->type = PEER_TASK_FINISH_CONNECT;
/* Even if the connect pended, the fd is now available. Set it up for events */
BAIL_ON_ERROR(status = lwmsg_task_set_trigger_fd(task->event_task, CONNECTION_PRIVATE(task->assoc)->fd));
/* Restore status code */
status = LWMSG_STATUS_PENDING;
lwmsg_peer_task_set_timeout(peer, task, &peer->timeout.establish, trigger, next_trigger, next_timeout);
break;
default:
BAIL_ON_ERROR(status = lwmsg_peer_task_handle_assoc_error(
peer,
task,
status));
break;
}
done:
return status;
error:
goto done;
}
示例3: lwmsg_peer_task_finish_transceive
static
LWMsgStatus
lwmsg_peer_task_finish_transceive(
LWMsgPeer* peer,
PeerAssocTask* task
)
{
LWMsgStatus status = LWMSG_STATUS_PENDING;
LWMsgMessage* message = NULL;
while ((!task->recv_blocked && task->incoming) ||
(!task->send_blocked && task->outgoing))
{
status = lwmsg_assoc_finish(task->assoc, &message);
switch (status)
{
case LWMSG_STATUS_SUCCESS:
if (message == &task->incoming_message)
{
task->incoming = LWMSG_FALSE;
task->recv_partial = LWMSG_FALSE;
BAIL_ON_ERROR(status = lwmsg_peer_task_dispatch_incoming_message(task));
}
else if (message == &task->outgoing_message)
{
lwmsg_peer_log_message(task, &task->outgoing_message, LWMSG_FALSE);
task->outgoing = LWMSG_FALSE;
if (task->destroy_outgoing)
{
lwmsg_assoc_destroy_message(task->assoc, &task->outgoing_message);
task->destroy_outgoing = LWMSG_FALSE;
}
}
break;
case LWMSG_STATUS_PENDING:
lwmsg_peer_task_update_blocked(task);
break;
default:
BAIL_ON_ERROR(status);
}
}
error:
return status;
}
示例4: lwmsg_peer_new
LWMsgStatus
lwmsg_peer_new(
const LWMsgContext* context,
LWMsgProtocol* protocol,
LWMsgPeer** out_peer
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
LWMsgPeer* peer = NULL;
BAIL_ON_ERROR(status = LWMSG_ALLOC(&peer));
lwmsg_ring_init(&peer->connect_endpoints);
lwmsg_ring_init(&peer->listen_endpoints);
memset(&peer->timeout, 0xFF, sizeof(peer->timeout));
peer->context = context;
BAIL_ON_ERROR(status = lwmsg_status_map_errno(pthread_mutex_init(&peer->lock, NULL)));
peer->lock_init = LWMSG_TRUE;
BAIL_ON_ERROR(status = lwmsg_status_map_errno(pthread_cond_init(&peer->event, NULL)));
peer->event_init = LWMSG_TRUE;
BAIL_ON_ERROR(status = lwmsg_task_acquire_manager(&peer->task_manager));
BAIL_ON_ERROR(status = lwmsg_task_group_new(peer->task_manager, &peer->connect_tasks));
peer->max_clients = 100;
peer->max_backlog = 8;
peer->protocol = protocol;
*out_peer = peer;
done:
return status;
error:
if (peer)
{
lwmsg_peer_delete(peer);
}
goto done;
}
示例5: lwmsg_data_unmarshal_indirect
static LWMsgStatus
lwmsg_data_unmarshal_indirect(
LWMsgDataContext* context,
LWMsgUnmarshalState* state,
LWMsgTypeIter* iter,
LWMsgTypeIter* inner,
LWMsgBuffer* buffer,
unsigned char* object,
size_t count
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
size_t i;
unsigned char* element = NULL;
if ((inner->kind == LWMSG_KIND_INTEGER ||
inner->kind == LWMSG_KIND_ENUM) &&
inner->info.kind_integer.width == 1 &&
inner->size == 1)
{
/* If the element type is an integer and the packed and unpacked sizes are both 1,
then we can copy directly from the marshalled data into the object. This
is an important optimization for unmarshalling character strings */
BAIL_ON_ERROR(status = lwmsg_buffer_read(buffer, object, count * inner->size));
}
else
{
/* Otherwise, we need to unmarshal each element individually */
element = object;
for (i = 0; i < count; i++)
{
BAIL_ON_ERROR(status = lwmsg_data_unmarshal_internal(
context,
state,
inner,
buffer,
element));
element += inner->size;
}
}
error:
return status;
}
示例6: VecsCreateCertStoreA
void client::AddTrustedRoot(
std::string Cert)
{
DWORD dwError = 0;
PVECS_STORE pStore = NULL;
dwError = VecsCreateCertStoreA(
(PSTR) ServerName.c_str(),
TRUSTED_ROOTS_STORE_NAME,
NULL,
&pStore);
if (dwError == ERROR_ALREADY_EXISTS)
{
dwError = VecsOpenCertStoreA(
(PSTR) ServerName.c_str(),
TRUSTED_ROOTS_STORE_NAME,
NULL,
&pStore);
}
BAIL_ON_ERROR(dwError);
dwError = VecsAddEntryA(
pStore,
CERT_ENTRY_TYPE_TRUSTED_CERT,
NULL,
(PSTR) Cert.c_str(),
NULL,
NULL,
0);
if (dwError == ERROR_ALREADY_EXISTS)
{
dwError = 0;
}
BAIL_ON_ERROR(dwError);
cleanup:
if (pStore)
{
VecsCloseCertStore(pStore);
}
return;
error:
THROW_IF_NEEDED(dwError);
goto cleanup;
}
示例7: lwmsg_assoc_print_message_alloc
LWMsgStatus
lwmsg_assoc_print_message_alloc(
LWMsgAssoc* assoc,
LWMsgMessage* message,
char** result
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
LWMsgDataContext* context = NULL;
LWMsgTypeSpec* type = NULL;
LWMsgBuffer buffer = {0};
const char* tag_name = NULL;
unsigned char nul = 0;
buffer.wrap = realloc_wrap;
buffer.data = (void*) &assoc->context;
BAIL_ON_ERROR(status = lwmsg_data_context_new(&assoc->context, &context));
BAIL_ON_ERROR(status = lwmsg_protocol_get_message_name(assoc->prot, message->tag, &tag_name));
BAIL_ON_ERROR(status = lwmsg_protocol_get_message_type(assoc->prot, message->tag, &type));
if (type)
{
BAIL_ON_ERROR(status = lwmsg_buffer_print(&buffer, "%s: ", tag_name));
BAIL_ON_ERROR(status = lwmsg_data_print_graph(
context,
type,
message->data,
4,
&buffer));
BAIL_ON_ERROR(status = lwmsg_buffer_write(&buffer, &nul, 1));
}
else
{
BAIL_ON_ERROR(status = lwmsg_buffer_print(&buffer, "%s", tag_name));
}
*result = (char*) buffer.base;
cleanup:
if (context)
{
lwmsg_data_context_delete(context);
}
return status;
error:
*result = NULL;
if (buffer.base)
{
lwmsg_context_free(&assoc->context, buffer.base);
}
goto cleanup;
}
示例8: lwmsg_archive_read_message_wrap_fd
static
LWMsgStatus
lwmsg_archive_read_message_wrap_fd (
LWMsgBuffer* buffer,
size_t needed
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
readinfo* info = buffer->data;
LWMsgArchive* archive = info->archive;
size_t count = 0;
if (needed)
{
/* Read next block of data from file */
if (info->remaining == 0)
{
/* The message was longer than the length specified in the header */
BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED);
}
else
{
BAIL_ON_ERROR(status = lwmsg_archive_read_fd(
archive,
info->data,
info->remaining > sizeof(info->data) ? sizeof(info->data) : info->remaining,
&count));
info->remaining -= count;
buffer->end = buffer->base + count;
buffer->cursor = buffer->base;
}
}
else
{
if (info->remaining != 0)
{
/* The message was shorter than the length specified in the header */
BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED);
}
}
error:
return status;
}
示例9: LwSmTableGetEntryReverseDependencyClosure
DWORD
LwSmTableGetEntryReverseDependencyClosure(
PSM_TABLE_ENTRY pEntry,
PWSTR** pppwszServiceList
)
{
DWORD dwError = 0;
PWSTR* ppwszServiceList = NULL;
PWSTR* ppwszAllServices = NULL;
dwError = LwAllocateMemory(sizeof(*ppwszServiceList) * 1, OUT_PPVOID(&ppwszServiceList));
BAIL_ON_ERROR(dwError);
dwError = LwSmTableEnumerateEntries(&ppwszAllServices);
BAIL_ON_ERROR(dwError);
dwError = LwSmTableGetEntryReverseDependencyClosureHelper(
pEntry,
ppwszAllServices,
&ppwszServiceList);
BAIL_ON_ERROR(dwError);
*pppwszServiceList = ppwszServiceList;
cleanup:
if (ppwszAllServices)
{
LwSmFreeStringList(ppwszAllServices);
}
return dwError;
error:
*pppwszServiceList = NULL;
if (ppwszServiceList)
{
LwSmFreeStringList(ppwszServiceList);
}
goto cleanup;
}
示例10: LwSmTableStartRecursive
static
DWORD
LwSmTableStartRecursive(
PSM_TABLE_ENTRY pEntry
)
{
DWORD error = 0;
PSM_TABLE_ENTRY pOtherEntry = NULL;
PWSTR* ppServices = NULL;
DWORD index = 0;
/* Start all dependencies */
error = LwSmTableGetEntryDependencyClosure(pEntry, &ppServices);
BAIL_ON_ERROR(error);
for (index = 0; ppServices[index]; index++)
{
error = LwSmTableGetEntry(ppServices[index], &pOtherEntry);
BAIL_ON_ERROR(error);
error = LwSmTableStartEntry(pOtherEntry);
BAIL_ON_ERROR(error);
LwSmTableReleaseEntry(pOtherEntry);
pOtherEntry = NULL;
}
error = LwSmTableStartEntry(pEntry);
BAIL_ON_ERROR(error);
error:
if (ppServices)
{
LwSmFreeStringList(ppServices);
}
if (pOtherEntry)
{
LwSmTableReleaseEntry(pOtherEntry);
}
return error;
}
示例11: LwSmConfigureLogging
static
DWORD
LwSmConfigureLogging(
PCSTR pszProgramName
)
{
DWORD dwError = 0;
LwSmLoggingInit(pszProgramName);
if (gState.logLevel == 0)
{
if (gState.bStartAsDaemon || (gState.bContainer && !gState.pGroup))
{
gState.logLevel = LW_SM_LOG_LEVEL_WARNING;
}
else
{
gState.logLevel = LW_SM_LOG_LEVEL_VERBOSE;
}
}
LwSmSetMaxLogLevel(NULL, gState.logLevel);
if (gState.pszLogFilePath)
{
dwError = LwSmSetLoggerToPath(NULL, gState.pszLogFilePath);
BAIL_ON_ERROR(dwError);
}
else if (gState.bSyslog)
{
dwError = LwSmSetLoggerToSyslog(NULL);
BAIL_ON_ERROR(dwError);
}
else
{
dwError = LwSmSetLoggerToFile(NULL, stderr);
BAIL_ON_ERROR(dwError);
}
error:
return dwError;
}
示例12: lwmsg_data_unmarshal_indirect_prologue
/* Find or unmarshal the length of a pointer or array */
static LWMsgStatus
lwmsg_data_unmarshal_indirect_prologue(
LWMsgDataContext* context,
LWMsgUnmarshalState* state,
LWMsgTypeIter* iter,
LWMsgTypeIter* inner,
LWMsgBuffer* buffer,
size_t* out_count
)
{
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
unsigned char temp[4];
switch (iter->info.kind_indirect.term)
{
case LWMSG_TERM_STATIC:
/* Static lengths are easy */
*out_count = iter->info.kind_indirect.term_info.static_length;
break;
case LWMSG_TERM_MEMBER:
/* The length is present in a member we have already unmarshalled */
BAIL_ON_ERROR(status = lwmsg_data_extract_length(
iter,
state->dominating_object,
out_count));
break;
case LWMSG_TERM_ZERO:
/* The length is present in the data stream as an unsigned 32-bit integer */
BAIL_ON_ERROR(status = lwmsg_buffer_read(buffer, temp, sizeof(temp)));
BAIL_ON_ERROR(status = lwmsg_convert_integer(
temp,
sizeof(temp),
context->byte_order,
out_count,
sizeof(*out_count),
LWMSG_NATIVE_ENDIAN,
LWMSG_UNSIGNED));
break;
}
error:
return status;
}
示例13: IdmJsonToPasswordResetRequestData
SSOERROR
IdmJsonToPasswordResetRequestData(
PCSSO_JSON pJson,
IDM_PASSWORD_RESET_REQUEST_DATA** ppPasswordResetRequest)
{
SSOERROR e = SSOERROR_NONE;
IDM_PASSWORD_RESET_REQUEST_DATA* pPasswordResetRequest = NULL;
if (pJson == NULL || ppPasswordResetRequest == NULL)
{
e = SSOERROR_INVALID_ARGUMENT;
BAIL_ON_ERROR(e);
}
e = SSOMemoryAllocate(sizeof(IDM_PASSWORD_RESET_REQUEST_DATA), (void**) &pPasswordResetRequest);
BAIL_ON_ERROR(e);
e = RestJsonToData(
pJson,
REST_JSON_OBJECT_TYPE_STRING,
NULL,
"currentPassword",
(void**) &(pPasswordResetRequest->currentPassword));
BAIL_ON_ERROR(e);
e = RestJsonToData(
pJson,
REST_JSON_OBJECT_TYPE_STRING,
NULL,
"newPassword",
(void**) &(pPasswordResetRequest->newPassword));
BAIL_ON_ERROR(e);
*ppPasswordResetRequest = pPasswordResetRequest;
error:
if (e != SSOERROR_NONE)
{
IdmPasswordResetRequestDataDelete(pPasswordResetRequest);
}
return e;
}
示例14: LwSmQueryServiceReverseDependencyClosure
DWORD
LwSmQueryServiceReverseDependencyClosure(
LW_SERVICE_HANDLE hHandle,
PWSTR** pppwszServiceList
)
{
DWORD dwError = 0;
PWSTR* ppwszServiceList = NULL;
PWSTR* ppwszAllServices = NULL;
dwError = LwAllocateMemory(sizeof(*ppwszServiceList) * 1, OUT_PPVOID(&ppwszServiceList));
BAIL_ON_ERROR(dwError);
dwError = LwSmEnumerateServices(&ppwszAllServices);
BAIL_ON_ERROR(dwError);
dwError = LwSmQueryServiceReverseDependencyClosureHelper(
hHandle,
ppwszAllServices,
&ppwszServiceList);
BAIL_ON_ERROR(dwError);
*pppwszServiceList = ppwszServiceList;
cleanup:
if (ppwszAllServices)
{
LwSmFreeStringList(ppwszAllServices);
}
return dwError;
error:
*pppwszServiceList = NULL;
if (ppwszServiceList)
{
LwSmFreeStringList(ppwszServiceList);
}
goto cleanup;
}
示例15: ConvertAnsitoUnicodeString
DWORD
ConvertAnsitoUnicodeString(
PCSTR pszSrc,
PWSTR* ppwszDst
)
{
DWORD dwError = 0;
#ifdef _WIN32
PSTR pszNewString = NULL;
#endif
if (!pszSrc || !ppwszDst)
{
dwError = ERROR_INVALID_PARAMETER;
}
else
{
#ifdef _WIN32
// allocate space for new string then pass addr to output
// double the original PSTR size for WPSTR
ULONG srcLen = (ULONG)strlen(pszSrc)+1;
ULONG destLen = (srcLen+1)*2;
dwError = VMCAAllocateMemory((DWORD) destLen, (PVOID*)&pszNewString);
BAIL_ON_ERROR(dwError);
if (0 == MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, (LPWSTR)pszNewString, destLen))
{
dwError = GetLastError();
BAIL_ON_ERROR(dwError);
}
*ppwszDst = (LPWSTR)pszNewString;
cleanup:
return dwError;
error:
VMCAFreeMemory(pszNewString);
goto cleanup;
#else
dwError = LwNtStatusToWin32Error(
LwRtlWC16StringAllocateFromCString(ppwszDst, pszSrc));
#endif
}
return dwError;
}