本文整理匯總了C++中ERROR_EXIT函數的典型用法代碼示例。如果您正苦於以下問題:C++ ERROR_EXIT函數的具體用法?C++ ERROR_EXIT怎麽用?C++ ERROR_EXIT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ERROR_EXIT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: main
int main()
{
#if defined(USE_DBC)
psocMemoryFile mem;
psocErrorHandler errorHandler;
bool ok;
psocMemoryFileStatus status;
/* The rename is a work around for a bug on Windows. It seems that the
* delete call (unlink) is not as synchroneous as it should be...
*/
rename( "MemFile.mem", "MemFile.old" );
unlink( "MemFile.old" );
psocInitErrorDefs();
psocInitErrorHandler( &errorHandler );
psocInitMemoryFile( &mem, 10, "MemFile.mem" );
ok = psocCreateBackstore( &mem, 0644, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
mem.initialized = 0;
psocBackStoreStatus( &mem, &status );
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
#else
return 1;
#endif
}
示例2: DEBUG_PRINTF
PdaDebugReturnCode
PciDevice_deleteDMABuffer
(
PciDevice *device,
DMABuffer *buffer
)
{
DEBUG_PRINTF(PDADEBUG_ENTER, "");
if(device == NULL)
{ ERROR_EXIT( EINVAL, exit, "Invalid pointer!\n" ); }
if(buffer == NULL)
{ ERROR_EXIT( EINVAL, exit, "Invalid pointer!\n" ); }
if(buffer == device->dma_buffer_list)
{
DMABuffer *head = NULL;
if(DMABuffer_getNext(buffer, &head) != PDA_SUCCESS)
{ ERROR_EXIT( EINVAL, exit, "get_next failed!\n" ); }
device->dma_buffer_list = head;
}
RETURN(DMABuffer_free(buffer, PDA_DELETE));
exit:
RETURN(EINVAL);
}
示例3: main
int main()
{
#if defined(USE_DBC)
psocMemoryFile mem;
psocErrorHandler errorHandler;
bool ok;
/* The rename is a work around for a bug on Windows. It seems that the delete
* call is not as synchroneous as it should be...
*/
rename( "MemFile.mem", "MemFile.old" );
unlink( "MemFile.old" );
psocInitErrorDefs();
psocInitErrorHandler( &errorHandler );
psocInitMemoryFile( &mem, 10, "MemFile.mem" );
ok = psocCreateBackstore( &mem, 0755, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
ok = psocOpenMemFile( &mem, NULL, &errorHandler );
unlink( "MemFile.mem" );
psocFiniMemoryFile( &mem );
psocFiniErrorHandler( &errorHandler );
psocFiniErrorDefs();
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
#else
return 1;
#endif
}
示例4: file_ReadFileEnd
/* Read a SW filemark, verify that it is a SW filemark, then skip to the next
* HW filemark. If the read of the SW filemark shows it's an EOF, then
* ignore that the SW filemark is not there and return 0 (found the SW filemark
* missing with some 3.1 dumps).
*/
static afs_int32
file_ReadFileEnd(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
afs_int32 blockType;
if (info->debug)
printf("butm: Read filemark end\n");
POLL();
info->error = 0;
code = check(info, READ_OP);
if (code)
ERROR_EXIT(code);
if (!READS || WRITES)
ERROR_EXIT(BUTM_BADOP);
info->status &= ~BUTM_STATUS_EOF;
code = ReadTapeBlock(info, tapeBlock, &blockType);
if (code)
ERROR_EXIT(code);
if ((blockType != BLOCK_FMEND) && (blockType != BLOCK_EOF))
ERROR_EXIT(BUTM_BADBLOCK);
error_exit:
return code;
}
示例5: CALLOC
/* -------------------------------------------------------- */
BOT* ircBOT_new (const char *nick, const char *pwd) {
/* -------------------------------------------------------- */
int x = 0;
BOT *bot = (BOT*) CALLOC(1, sizeof(BOT));
if(bot) {
if(!nick)
ERROR_EXIT("ircBOT_new: Error no NICK!!!\n");
bot->nick = strdup(nick);
if(pwd)
bot->pwd = strdup(pwd);
else
bot->pwd = NULL;
bot->srv.state = IRC_SYS_NEEDCONNECT;
bot->srv.sendbuf = NULL;
bot->cmd_handler = LIST_new();
bot->tee_handler = LIST_new();
for(x=0; x<MAX_TIMER; x++)
bot->timer[x].id = -1;
}
/* add this bot to the global ones */
if(!all_bots)
all_bots = LIST_new();
if(!LIST_add(all_bots, bot))
ERROR_EXIT("ircBOT_new: Error adding bot to global BOT-List!!\n");
DEBUG("BOT with nick '%s' created.\n", bot->nick);
return bot;
};
示例6: file_WriteEODump
/*
* Write the end-of-dump marker.
*/
static afs_int32
file_WriteEODump(struct butm_tapeInfo *info)
{
afs_int32 code = 0;
if (info->debug)
printf("butm: Write filemark EOD\n");
POLL();
info->error = 0;
code = check(info, WRITE_OP);
if (code)
ERROR_EXIT(code);
if (READS || WRITES)
ERROR_EXIT(BUTM_BADOP);
code = WriteTapeBlock(info, tapeBlock, BUTM_BLOCKSIZE, BLOCK_EOD);
if (code)
ERROR_EXIT(code);
info->status |= BUTM_STATUS_EOD;
error_exit:
return (code);
}
示例7: main
int main()
{
pid_t pid;
int fd;
char buff[BUFF_SIZE];
if (-1 == (fd = open("/tmp/ipc", O_CREAT | O_RDWR, 0777)))
ERROR_EXIT("pipe");
pid = fork();
if (0 == pid) { /* child */
memset(buff, 0, BUFF_SIZE);
if (0 >= read(fd, buff, BUFF_SIZE))
ERROR_EXIT("read");
printf("read: %s\n", buff);
}else if (0 < pid) { /* father */
sleep(1);
strcpy(buff, "helloworld");
if (0 >= write(fd, buff, strlen(buff)))
ERROR_EXIT("write");
printf("write: %s\n", buff);
}
exit(EXIT_SUCCESS);
return 0;
}
示例8: priv_sock_recv_str
void priv_sock_recv_str(int fd, char *buf, int len)
{
int rlen = priv_sock_recv_int(fd);
if (rlen > len)
ERROR_EXIT("priv_sock_recv_str");
if (readn(fd, buf, rlen) != rlen)
ERROR_EXIT("priv_sock_recv_str");
}
示例9: evtchn_bind_pirq
static long evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
{
struct evtchn *chn;
struct domain *d = current->domain;
struct vcpu *v = d->vcpu[0];
struct pirq *info;
int port, pirq = bind->pirq;
long rc;
if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
return -EINVAL;
if ( !is_hvm_domain(d) && !irq_access_permitted(d, pirq) )
return -EPERM;
spin_lock(&d->event_lock);
if ( pirq_to_evtchn(d, pirq) != 0 )
ERROR_EXIT(-EEXIST);
if ( (port = get_free_port(d)) < 0 )
ERROR_EXIT(port);
chn = evtchn_from_port(d, port);
info = pirq_get_info(d, pirq);
if ( !info )
ERROR_EXIT(-ENOMEM);
info->evtchn = port;
rc = (!is_hvm_domain(d)
? pirq_guest_bind(v, info,
!!(bind->flags & BIND_PIRQ__WILL_SHARE))
: 0);
if ( rc != 0 )
{
info->evtchn = 0;
pirq_cleanup_check(info, d);
goto out;
}
chn->state = ECS_PIRQ;
chn->u.pirq.irq = pirq;
link_pirq_port(port, chn, v);
bind->port = port;
#ifdef CONFIG_X86
if ( is_hvm_domain(d) && domain_pirq_to_irq(d, pirq) > 0 )
map_domain_emuirq_pirq(d, pirq, IRQ_PT);
#endif
out:
spin_unlock(&d->event_lock);
return rc;
}
示例10: file_WriteFileData
/* Writes data out in block sizes of 16KB. Does destroy the data.
* Assumes the data buffer has a space reserved at beginning for a blockMark.
*/
static afs_int32
file_WriteFileData(struct butm_tapeInfo *info, char *data, afs_int32 blocks, afs_int32 len)
{
afs_int32 code = 0;
int length;
afs_int32 b;
char *bstart; /* Where block starts for a 16K block */
char *dstart; /* Where data starts for a 16K block */
if (info->debug)
printf("butm: Write tape data - %u bytes\n", len);
POLL();
info->error = 0;
code = check(info, WRITE_OP);
if (code)
ERROR_EXIT(code);
if (!data || (len < 0))
ERROR_EXIT(BUTM_BADARGUMENT);
if (READS || !WRITES)
ERROR_EXIT(BUTM_BADOP);
b = 0; /* start at block 0 */
while (len > 0) {
dstart = &data[b * BUTM_BLKSIZE];
bstart = dstart - sizeof(struct blockMark);
if (len < BUTM_BLKSIZE) {
memset(&dstart[len], 0, BUTM_BLKSIZE - len);
length = len;
} else {
length = BUTM_BLKSIZE;
}
code = WriteTapeBlock(info, bstart, length, BLOCK_DATA);
len -= length;
/* If there are more blocks, step to next block */
/* Otherwise, copy the data to beginning of last block */
if (b < (blocks - 1))
b++;
else if (len)
memcpy(&dstart[0], &dstart[BUTM_BLKSIZE], len);
}
error_exit:
return (code);
}
示例11: main
int main()
{
psocMemoryFile mem;
psocErrorHandler errorHandler;
void * pAddr = NULL;
bool ok;
#if ! defined(WIN32)
struct sigaction newAction, oldAction;
#endif
/* The rename is a work around for a bug on Windows. It seems that the delete
* call is not as synchroneous as it should be...
*/
rename( "MemFile.mem", "MemFile.old" );
unlink( "MemFile.old" );
psocInitErrorDefs();
psocInitErrorHandler( &errorHandler );
psocInitMemoryFile( &mem, 10, "MemFile.mem" );
ok = psocCreateBackstore( &mem, 0755, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
ok = psocOpenMemFile( &mem, &pAddr, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
ok = psocSetReadOnly( &mem, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
/* This should crash the whole thing. We intercept it with a signal.
* This way, if there is no memory violation, we will know.
*/
#if defined(WIN32)
signal(SIGSEGV, signalHandler );
#else
newAction.sa_handler = signalHandler;
newAction.sa_flags = SA_RESTART;
sigaction( SIGSEGV, &newAction, &oldAction );
#endif
((char*)pAddr)[0] = 'x';
((char*)pAddr)[1] = 'y';
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
}
示例12: file_SeekEODump
/*
* Seek to the EODump (end-of-dump) after the given position. This is
* the position after the EOF filemark immediately after the EODump mark.
* This is for tapes of version 4 or greater.
*/
static afs_int32
file_SeekEODump(struct butm_tapeInfo *info, afs_int32 position)
{
afs_int32 code = 0;
afs_int32 blockType;
afs_int32 w;
struct progress *p;
afs_int64 stopOff; /* file seek offsets */
if (info->debug)
printf("butm: Seek to end-of-dump\n");
info->error = 0;
code = check(info, READ_OP);
if (code)
ERROR_EXIT(code);
if (READS || WRITES)
ERROR_EXIT(BUTM_BADOP);
if (isafile) {
p = (struct progress *)info->tmRock;
w = USD_SEEK(p->fid, 0, SEEK_END, &stopOff);
if (w) {
info->error = w;
ERROR_EXIT(BUTM_POSITION);
}
if (stopOff % BUTM_BLOCKSIZE)
ERROR_EXIT(BUTM_POSITION);
info->position = (stopOff / BUTM_BLOCKSIZE);
} else {
/* Seek to the desired position */
code = SeekFile(info, (position - info->position) + 1);
if (code)
ERROR_EXIT(code);
/*
* Search until the filemark is an EODump filemark.
* Skip over volumes only.
*/
while (1) {
code = ReadTapeBlock(info, tapeBlock, &blockType);
if (code)
ERROR_EXIT(code);
if (blockType == BLOCK_EOD)
break;
if (blockType != BLOCK_FMBEGIN)
ERROR_EXIT(BUTM_BADBLOCK);
code = SeekFile(info, 1); /* Step forward to next volume */
if (code)
ERROR_EXIT(code);
}
code = 0;
}
error_exit:
return (code);
}
示例13: main
int main()
{
psocMemoryFile mem;
psocErrorHandler errorHandler;
void* pAddr = NULL;
bool ok;
/* The rename is a work around for a bug on Windows. It seems that the delete
* call is not as synchroneous as it should be...
*/
rename( "MemFile.mem", "MemFile.old" );
unlink( "MemFile.old" );
psocInitErrorDefs();
psocInitErrorHandler( &errorHandler );
psocInitMemoryFile( &mem, 10, "MemFile.mem" );
ok = psocCreateBackstore( &mem, 0755, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
ok = psocOpenMemFile( &mem, &pAddr, &errorHandler );
if ( ok != true ) {
ERROR_EXIT( expectedToPass, &errorHandler, unlink( "MemFile.mem" ) );
}
psocCloseMemFile( &mem, &errorHandler );
if ( mem.fileHandle != PSO_INVALID_HANDLE ) {
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
}
if ( mem.baseAddr != PSO_MAP_FAILED ) {
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
}
#if defined (WIN32)
if ( mem.mapHandle != PSO_INVALID_HANDLE ) {
ERROR_EXIT( expectedToPass, NULL, unlink( "MemFile.mem" ) );
}
#endif
unlink( "MemFile.mem" );
psocFiniMemoryFile( &mem );
psocFiniErrorHandler( &errorHandler );
psocFiniErrorDefs();
return 0;
}
示例14: evtchn_bind_pirq
static long evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
{
struct evtchn *chn;
struct domain *d = current->domain;
struct vcpu *v = d->vcpu[0];
int port, pirq = bind->pirq;
long rc;
if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
return -EINVAL;
if ( !is_hvm_domain(d) && !irq_access_permitted(d, pirq) )
return -EPERM;
spin_lock(&d->event_lock);
if ( d->pirq_to_evtchn[pirq] != 0 )
ERROR_EXIT(-EEXIST);
if ( (port = get_free_port(d)) < 0 )
ERROR_EXIT(port);
chn = evtchn_from_port(d, port);
d->pirq_to_evtchn[pirq] = port;
rc = (!is_hvm_domain(d)
? pirq_guest_bind(
v, pirq, !!(bind->flags & BIND_PIRQ__WILL_SHARE))
: 0);
if ( rc != 0 )
{
d->pirq_to_evtchn[pirq] = 0;
goto out;
}
chn->state = ECS_PIRQ;
chn->u.pirq.irq = pirq;
link_pirq_port(port, chn, v);
bind->port = port;
if ( is_hvm_domain(d) && domain_pirq_to_irq(d, pirq) > 0 )
map_domain_emuirq_pirq(d, pirq, IRQ_PT);
out:
spin_unlock(&d->event_lock);
return rc;
}
示例15: mapnode_new
mapnode_t *
mapnode_new()
{
mapnode_t *ptr;
ptr = calloc(1, sizeof(mapnode_t));
if (!ptr)
ERROR_EXIT();
ptr->adj = calloc(1, sizeof(struct adj_st));
if (!ptr->adj)
ERROR_EXIT();
return ptr;
}