本文整理汇总了C++中CHK函数的典型用法代码示例。如果您正苦于以下问题:C++ CHK函数的具体用法?C++ CHK怎么用?C++ CHK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gread
void
gread(struct termios *tp, char *s)
{
const struct cchar *cp;
char *ep, *p;
long tmp;
if ((s = strchr(s, ':')) == NULL)
gerr(NULL);
for (++s; s != NULL;) {
p = strsep(&s, ":\0");
if (!p || !*p)
break;
if (!(ep = strchr(p, '=')))
gerr(p);
*ep++ = '\0';
(void)sscanf(ep, "%lx", &tmp);
#define CHK(s) (*p == s[0] && !strcmp(p, s))
if (CHK("cflag")) {
tp->c_cflag = tmp;
continue;
}
if (CHK("iflag")) {
tp->c_iflag = tmp;
continue;
}
if (CHK("ispeed")) {
(void)sscanf(ep, "%ld", &tmp);
tp->c_ispeed = tmp;
continue;
}
if (CHK("lflag")) {
tp->c_lflag = tmp;
continue;
}
if (CHK("oflag")) {
tp->c_oflag = tmp;
continue;
}
if (CHK("ospeed")) {
(void)sscanf(ep, "%ld", &tmp);
tp->c_ospeed = tmp;
continue;
}
for (cp = cchars1; cp->name != NULL; ++cp)
if (CHK(cp->name)) {
tp->c_cc[cp->sub] = tmp;
break;
}
if (cp->name == NULL)
gerr(p);
}
}
开发者ID:Bluerise,项目名称:openbsd-src,代码行数:54,代码来源:gfmt.c
示例2: BMessageRunner
/*
BMessageRunner(BMessenger target, const BMessage *message,
bigtime_t interval, int32 count)
@case 3 target is valid, message is valid, interval == 0, count > 0
@results R5: InitCheck() should return B_ERROR.
GetInfo() should return B_BAD_VALUE.
OBOS: InitCheck() should return B_OK.
GetInfo() should return B_OK.
A minimal time interval is used (50000).
*/
void TBMessageRunnerTester::BMessageRunnerA3()
{
MessageRunnerTestApp app(kTesterSignature);
MessageRunnerTestLooper *looper = app.TestLooper();
BMessenger target(looper);
BMessage message(MSG_RUNNER_MESSAGE);
bigtime_t interval = 0;
int32 count = 5;
BMessageRunner runner(target, &message, interval, count);
#ifdef TEST_R5
CHK(runner.InitCheck() == B_ERROR);
check_message_runner_info(runner, B_BAD_VALUE);
#else
bigtime_t startTime = system_time();
CHK(runner.InitCheck() == B_OK);
interval = max(interval, kMinTimeInterval);
check_message_runner_info(runner, B_OK, interval, count);
snooze((count + 1) * interval + 10000);
CHK(looper->CheckMessages(startTime, interval, count));
CHK(app.CountReplies() == count);
#endif
}
开发者ID:mariuz,项目名称:haiku,代码行数:32,代码来源:BMessageRunnerTester.cpp
示例3: channelTestFamily_done
utilStatus channelTestFamily_done( channelTestFamily * This ) {
utilStatus status = UTIL_STATUS_NO_ERROR;
if( This ) {
unsigned i;
if( This->parent2 ) {
CHK(__FILE__,__LINE__,channelTestPerson_delete( &This->parent2 ))
}
for( i = 0; i < This->children.count; ++i ) {
CHK(__FILE__,__LINE__,channelTestPerson_delete( &This->children.items[i] ))
}
CHK(__FILE__,__LINE__,channelList_done((channelList *)&This->children ))
}
else {
开发者ID:AubinMahe,项目名称:dcrud,代码行数:13,代码来源:Family.c
示例4: cli_fault_injection_dev_addr
int cli_fault_injection_dev_addr(char *line, int num_of_args)
{
char fault_num_str[MAX_ARG_SIZE];
char dev_addr_str[MAX_ARG_SIZE];
int fault_num;
int dev_addr;
/* Get number of fault injection */
CHK(cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2));
/* Get device address */
CHK(cli_get_word(line, dev_addr_str, sizeof(dev_addr_str), 3));
/* Convert strings to int */
fault_num = atoi(fault_num_str) - 1;
dev_addr = (int) strtol(dev_addr_str, (char **) &dev_addr_str, 16);
CHK(cfg_set_fault_injection_dev_address(fault_num, (unsigned char) dev_addr));
return 0;
}
开发者ID:redivo,项目名称:tcc,代码行数:22,代码来源:cli_fault_injection.c
示例5: GetAppList
/*
void GetAppList(const char *signature, BList *teamIDList) const
@case 2 teamIDList is not NULL and not empty, signature is not
NULL, but no app with this signature is running
@results Should not modify teamIDList.
*/
void GetAppListTester::GetAppListTestB2()
{
const char *signature = "application/x-vnd.obos-does-not-exist";
// create a list with some dummy entries
BList list;
list.AddItem((void*)-7);
list.AddItem((void*)-42);
// get a list of running applications for reference
BRoster roster;
BList list1(list);
roster.GetAppList(signature, &list1);
// run some apps
AppRunner runner1(true);
AppRunner runner2(true);
AppRunner runner3(true);
CHK(runner1.Run("AppRunTestApp1") == B_OK);
CHK(runner2.Run("AppRunTestApp2") == B_OK);
CHK(runner3.Run("BMessengerTestApp1") == B_OK);
BList expectedApps;
// get a new app list and check it
BList list2(list);
roster.GetAppList(signature, &list2);
check_list(list2, list, list1, expectedApps);
// quit app 1
runner1.WaitFor(true);
BList list3(list);
roster.GetAppList(signature, &list3);
check_list(list3, list, list1, expectedApps);
// quit app 2
runner2.WaitFor(true);
BList list4(list);
roster.GetAppList(signature, &list4);
check_list(list4, list, list1, expectedApps);
// quit app 3
runner3.WaitFor(true);
BList list5(list);
roster.GetAppList(signature, &list5);
check_list(list5, list, list1, expectedApps);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:45,代码来源:GetAppListTester.cpp
示例6: IteratorForIndex
inline ConstIterator IteratorForIndex(int32 index) const
{
if (index < 0 || index > Count()) {
CHK(fMyVector.IteratorForIndex(index) == fMyVector.End());
return End();
} else {
MyIterator myIt = fMyVector.IteratorForIndex(index);
ReferenceIterator it = fReferenceVector.begin();
for (int32 i = 0; i < index; i++)
++it;
return ConstIterator(this, myIt, it);
}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:13,代码来源:VectorTest.cpp
示例7: TestDir15
uint TestDir15(void)
{
tIORes res;
uint result = 1;
tReadDirState ReadDirState;
tFATDirectoryEntry DirEntry;
// tFATFSStatus FSStatus2;
FAT_opendir (&stdio_FATFS, &res, "d:\\", &ReadDirState);
CHK(res == ior_OK);
FAT_readdir (&stdio_FATFS, &res, &ReadDirState, &DirEntry);
CHK(res == ior_NO_MORE_FILES);
FAT_closedir (&stdio_FATFS, &res, &ReadDirState);
CHK(res == ior_OK);
result = 0;
lend:
return result;
}
开发者ID:vn2019,项目名称:epos,代码行数:22,代码来源:testcase.c
示例8: main
int main(int argc, char **argv)
{
/* create dummy pixmap to get initialization out of the way */
c2d_ts_handle curTimestamp;
PixmapPtr tmp = create_pixmap(64, 64, xRGB);
CHK(c2dFlush(tmp->id, &curTimestamp));
CHK(c2dWaitTimestamp(curTimestamp));
/*
[ 1340.257] (II) freedreno(0): MSMCheckComposite:590 op:12: 0x2eb268 {20028888, 0} <- 0x2eb3a8 {08018000, 0} ((nil) {00000000, 0})
[ 1340.257] (II) freedreno(0): MSMPrepareComposite:694 0x2eb178 {35x8,256} <- 0x2eb2c8 {1024x320,1024} ((nil) {0x0,0})
[ 1340.258] (II) freedreno(0): MSMComposite:766 srcX=0 srcY=0 maskX=0 maskY=0 dstX=0 dstY=2 width=7 height=6
*/
test_composite(C2D_ALPHA_BLEND_ADDITIVE,
ARGB, 35, 8,
A8, 1024, 320,
0, 0, 0,
0, 0, 0, 0, 0, 2, 7, 6);
return 0;
}
开发者ID:downthemachine,项目名称:freedreno,代码行数:22,代码来源:test-composite2.c
示例9: ctr_drbg_self_test
/*
* Checkup routine
*/
int ctr_drbg_self_test( int verbose )
{
ctr_drbg_context ctx;
unsigned char buf[16];
/*
* Based on a NIST CTR_DRBG test vector (PR = True)
*/
if( verbose != 0 )
polarssl_printf( " CTR_DRBG (PR = TRUE) : " );
test_offset = 0;
CHK( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy,
entropy_source_pr, nonce_pers_pr, 16, 32 ) );
ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON );
CHK( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) );
CHK( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) );
CHK( memcmp( buf, result_pr, CTR_DRBG_BLOCKSIZE ) );
if( verbose != 0 )
polarssl_printf( "passed\n" );
/*
* Based on a NIST CTR_DRBG test vector (PR = FALSE)
*/
if( verbose != 0 )
polarssl_printf( " CTR_DRBG (PR = FALSE): " );
test_offset = 0;
CHK( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy,
entropy_source_nopr, nonce_pers_nopr, 16, 32 ) );
CHK( ctr_drbg_random( &ctx, buf, 16 ) );
CHK( ctr_drbg_reseed( &ctx, NULL, 0 ) );
CHK( ctr_drbg_random( &ctx, buf, 16 ) );
CHK( memcmp( buf, result_nopr, 16 ) );
if( verbose != 0 )
polarssl_printf( "passed\n" );
if( verbose != 0 )
polarssl_printf( "\n" );
return( 0 );
}
开发者ID:cwyiu,项目名称:fibjs,代码行数:47,代码来源:ctr_drbg.c
示例10: chunk_write
/* writting from chunk */
int chunk_write(void *chunk, int fd)
{
int n = -1;
if(chunk && fd > 0 && CHK(chunk)->left > 0 && CHK(chunk)->data && CHK(chunk)->end
&& (n = write(fd, CHK(chunk)->end, CHK(chunk)->left)) > 0)
{
CHK(chunk)->left -= n;
CHK(chunk)->end += n;
}
return n;
}
开发者ID:houweifeng,项目名称:sbase,代码行数:13,代码来源:chunk.c
示例11: calc_afe_blacklevel
/*
* Calculate and set the AFE offset.
*
* low: known-good AFE offset-register value. See note.
* high: known-good AFE offset-register value. See note.
*
* Note:
* 'low' and 'high' depend on the scanner model.
* Choose them so that
* 1. both produce black pixel samples > 0, and never zero.
* 2. 'low' produces a a darker black level than 'high',
* 3. 'low' and 'high' values are as far apart as possible,
* for better precision.
* Example: For CanoScan 4400F, select low = 75, high = 0.
* Notice that the 'low' register value is not necessarily
* less than the 'high' register value. It is what comes
* out of the scanner that counts.
*/
static int calc_afe_blacklevel(struct gl843_device *dev,
struct calibration_info *cal,
uint8_t low, uint8_t high)
{
int ret, i;
struct gl843_image *img;
struct img_stat lo_stat, hi_stat;
DBG(DBG_msg, "Calibrating A/D-converter black level.\n");
CHK_MEM(img = create_image(cal->width, cal->height, PXFMT_RGB16));
/* Scan with the lamp off to produce black pixels. */
CHK(set_lamp(dev, LAMP_OFF, 0));
/* Sample 'low' black level */
for (i = 0; i < 3; i++) {
CHK(write_afe_gain(dev, i, 1.0));
CHK(write_afe(dev, 32 + i, low)); /* Set 'low' black level */
}
CHK(scan_img(dev, img, 10000));
get_image_stats(img, &lo_stat);
/* Sample 'high' black level */
for (i = 0; i < 3; i++) {
CHK(write_afe(dev, 32 + i, high)); /* Set 'high' black level */
}
CHK(scan_img(dev, img, 10000));
get_image_stats(img, &hi_stat);
/* Use the line equation to find and set the best offset value */
for (i = 0; i < 3; i++) {
double m, c; /* y = mx + c */
int o; /* offset */
m = (hi_stat.avg[i] - lo_stat.avg[i]) / (high - low);
c = lo_stat.avg[i] - m * low;
o = (int) satf(-c / m + 0.5, 0, 255);
cal->offset[i] = o;
CHK(write_afe(dev, 32 + i, o));
DBG(DBG_info, "AFE %s offset = %d\n", idx_name(i), o);
}
ret = 0;
chk_failed:
free(img);
return ret;
chk_mem_failed:
ret = LIBUSB_ERROR_NO_MEM;
goto chk_failed;
}
开发者ID:AndreySV,项目名称:gl843driver,代码行数:71,代码来源:scan.c
示例12: msearch
int
msearch(char ***argvp, struct info *ip)
{
struct modes *mp;
char *name;
name = **argvp;
for (mp = cmodes; mp->name; ++mp)
if (CHK(mp->name)) {
ip->t.c_cflag &= ~mp->unset;
ip->t.c_cflag |= mp->set;
ip->set = 1;
return (1);
}
for (mp = imodes; mp->name; ++mp)
if (CHK(mp->name)) {
ip->t.c_iflag &= ~mp->unset;
ip->t.c_iflag |= mp->set;
ip->set = 1;
return (1);
}
for (mp = lmodes; mp->name; ++mp)
if (CHK(mp->name)) {
ip->t.c_lflag &= ~mp->unset;
ip->t.c_lflag |= mp->set;
ip->set = 1;
return (1);
}
for (mp = omodes; mp->name; ++mp)
if (CHK(mp->name)) {
ip->t.c_oflag &= ~mp->unset;
ip->t.c_oflag |= mp->set;
ip->set = 1;
return (1);
}
return (0);
}
开发者ID:daniloegea,项目名称:freebsd,代码行数:38,代码来源:modes.c
示例13: main
int main(int argc, char **argv)
{
/* create dummy pixmap to get initialization out of the way */
c2d_ts_handle curTimestamp;
PixmapPtr tmp = create_pixmap(64, 64, xRGB);
CHK(c2dFlush(tmp->id, &curTimestamp));
CHK(c2dWaitTimestamp(curTimestamp));
test_fill(1920, 1080, xRGB, 0, 0, 1920, 1080);
test_fill(1920, 1080, xRGB, 717, 395, 718, 685);
/* test limits of x, y */
test_fill(1920, 1080, xRGB, 0x100, 0, 0x101, 0);
test_fill(1920, 1080, xRGB, 0, 0x100, 0, 0x101);
/* test limits of width, height */
test_fill(1920, 1080, xRGB, 0, 0, 0x100, 0);
test_fill(1920, 1080, xRGB, 0, 0, 0, 0x100);
test_fill(1, 1, xRGB, 0, 0, 1, 1);
return 0;
}
开发者ID:maclaw,项目名称:freedreno,代码行数:23,代码来源:test-fill2.c
示例14: cli_fault_injection_gen_read_en
int cli_fault_injection_gen_read_en(char *line, int num_of_args)
{
char fault_num_str[MAX_ARG_SIZE];
char en_value_str[MAX_ARG_SIZE];
int fault_num;
int en_value;
/* Get number of fault injection */
CHK(cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2));
/* Get enable value */
CHK(cli_get_word(line, en_value_str, sizeof(en_value_str), 3));
/* Convert strings to int */
fault_num = atoi(fault_num_str) - 1;
en_value = atoi(en_value_str);
CHK(cfg_set_fault_injection_read_enable(fault_num, en_value));
return 0;
return 0;
}
开发者ID:redivo,项目名称:tcc,代码行数:23,代码来源:cli_fault_injection.c
示例15: TestDir13
uint TestDir13(void)
{
tIORes res;
uint result = 1;
// tFATFSStatus FSStatus1;
FAT_mkdir (&stdio_FATFS, &res, "d:\\level1", mt_S_IWUSR);
CHK(res == ior_OK);
result = 0;
lend:
return result;
}
开发者ID:vn2019,项目名称:epos,代码行数:14,代码来源:testcase.c
示例16: cfg_set_fault_injection_dev_address
int cfg_set_fault_injection_dev_address(int index, unsigned char address)
{
if (!IS_VALID_FAULT_INJECTION_INDEX(index))
return ERR_INVALID_PARAM;
if (!IS_VALID_DEV_ADDR(address))
return ERR_INVALID_PARAM;
CHK(hw_set_i2c_address(FI_INDEX_TO_I2C_NUMBER(index), address));
Cfg.i2c_fi[index].dev_address = address;
return 0;
}
开发者ID:redivo,项目名称:tcc,代码行数:14,代码来源:cfg_i2c.c
示例17: IntArrayListImport
ESR_ReturnCode IntArrayListImport(int* value, IntArrayList** self)
{
ESR_ReturnCode rc;
IntArrayListImpl* impl;
if (self == NULL)
return ESR_INVALID_ARGUMENT;
CHK(rc, IntArrayListCreate(self));
impl = (IntArrayListImpl*) self;
impl->contents = value;
return ESR_SUCCESS;
CLEANUP:
return rc;
}
开发者ID:0omega,项目名称:platform_external_srec,代码行数:14,代码来源:IntArrayListImpl.c
示例18: check_list
// check_list
static
void
check_list(const BList &toCheck, const BList &base, const BList &extendedBase,
const BList &expected)
{
// toCheck and extendedBase must have prefix base
int32 baseCount = base.CountItems();
for (int32 i = 0; i < baseCount; i++) {
CHK(base.ItemAt(i) == toCheck.ItemAt(i));
CHK(base.ItemAt(i) == extendedBase.ItemAt(i));
}
// toCheck must have correct size
int32 toCheckCount = toCheck.CountItems();
int32 extendedBaseCount = extendedBase.CountItems();
int32 expectedCount = expected.CountItems();
CHK(toCheckCount == extendedBaseCount + expectedCount);
// toCheck must contain all elements of extendedBase and expected
// (arbitrary order)
BList list(extendedBase);
list.AddList((BList*)&expected);
CHK(contains_list(toCheck, list));
CHK(contains_list(list, toCheck));
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:24,代码来源:GetAppListTester.cpp
示例19: SR_EventLog_TokenSize_t
ESR_ReturnCode SR_EventLog_TokenSize_t(SR_EventLog* self, const LCHAR* token, size_t value)
{
SR_EventLogImpl *impl = (SR_EventLogImpl *)self;
ESR_ReturnCode rc;
LCHAR alpha[MAX_UINT_DIGITS+1];
size_t size = MAX_INT_DIGITS+1;
if (impl->logLevel == 0)
return ESR_SUCCESS;
CHK(rc, lultostr(value, alpha, &size, 10));
return self->token(self, token, alpha);
CLEANUP:
return rc;
}
开发者ID:CriGio,项目名称:platform_external_srec,代码行数:14,代码来源:EventLogImpl.c
示例20: open_socket
static void open_socket (int port)
{
struct sockaddr_in my_addr;
int sock = socket(AF_INET, SOCK_STREAM, 0);
CHK(sock);
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
my_addr.sin_port = htons(port);
my_addr.sin_family = AF_INET;
int optval = 1;
CHK(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval));
CHK(bind(sock,(struct sockaddr *)&my_addr,sizeof(struct sockaddr_in)));
CHK(listen(sock,1));
sockfd = accept(sock,&bot_addr, &bot_addrlen);
CHK(sockfd);
close(sock);
char msg[MAX_MSG_SIZE] ;
recv(sockfd,msg,MAX_MSG_SIZE,0);
int wlen = 4;
if (strncmp(msg, "NAME", wlen) == 0) {
mm_botname(msg + wlen + 1,word_len(msg+wlen+1));
}
}
开发者ID:lleclech,项目名称:PFA-Nethack-teamB,代码行数:23,代码来源:bot_handler.c
注:本文中的CHK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论