当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_RETURN函数代码示例

本文整理汇总了C++中CHECK_RETURN函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_RETURN函数的具体用法?C++ CHECK_RETURN怎么用?C++ CHECK_RETURN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CHECK_RETURN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CHECK_RETURN

const char* Card::can_attack(Game* g, Player* p) const {
    CHECK_RETURN(controller == p);
    CHECK_RETURN(!tapped);
    CHECK_RETURN(has_text("creature"));
    CHECK_RETURN(!sick || has_ability("haste"));
    return nullptr;
}
开发者ID:ras0219,项目名称:mtgbreaker,代码行数:7,代码来源:card.cpp

示例2: broadcast_angles

int broadcast_angles()
{
#if defined(THREEBODY)
  int num_angles = 0;
  angle_t angle;
  atom_t* atom = NULL;

  memset(&angle, 0, sizeof(angle));

  for (int i = 0; i < g_config.natoms; ++i) {
    atom = g_config.conf_atoms + i - g_mpi.firstatom;
    if (g_mpi.myid == 0)
      num_angles = g_config.atoms[i].num_angles;
    CHECK_RETURN(MPI_Bcast(&num_angles, 1, MPI_INT, 0, MPI_COMM_WORLD));
    if (i >= g_mpi.firstatom && i < (g_mpi.firstatom + g_mpi.myatoms)) {
      atom->angle_part = (angle_t*)Malloc(num_angles * sizeof(angle_t));
      for (int j = 0; j < num_angles; ++j)
        memset(atom->angle_part + j, 0, sizeof(angle_t));
    }
    for (int j = 0; j < num_angles; ++j) {
      if (g_mpi.myid == 0)
        angle = g_config.atoms[i].angle_part[j];
      CHECK_RETURN(MPI_Bcast(&angle, 1, g_mpi.MPI_ANGL, 0, MPI_COMM_WORLD));
      if (i >= g_mpi.firstatom && i < (g_mpi.firstatom + g_mpi.myatoms))
        atom->angle_part[j] = angle;
    }
  }
#endif  // THREEBODY

  return MPI_SUCCESS;
}
开发者ID:arielzn,项目名称:potfit,代码行数:31,代码来源:mpi_utils.c

示例3: broadcast_neighbors

int broadcast_neighbors()
{
  int num_neighs = 0;
  neigh_t neigh;
  atom_t* atom = NULL;

  memset(&neigh, 0, sizeof(neigh));

  for (int i = 0; i < g_config.natoms; ++i) {
    atom = g_config.conf_atoms + i - g_mpi.firstatom;
    if (g_mpi.myid == 0)
      num_neighs = g_config.atoms[i].num_neigh;
    CHECK_RETURN(MPI_Bcast(&num_neighs, 1, MPI_INT, 0, MPI_COMM_WORLD));
    if (num_neighs > 0 && i >= g_mpi.firstatom &&
        i < (g_mpi.firstatom + g_mpi.myatoms)) {
      atom->neigh = (neigh_t*)Malloc(num_neighs * sizeof(neigh_t));
      for (int j = 0; j < num_neighs; ++j)
        memset(atom->neigh + j, 0, sizeof(neigh_t));
    }
    for (int j = 0; j < num_neighs; ++j) {
      if (g_mpi.myid == 0)
        neigh = g_config.atoms[i].neigh[j];
      CHECK_RETURN(MPI_Bcast(&neigh, 1, g_mpi.MPI_NEIGH, 0, MPI_COMM_WORLD));
      if (i >= g_mpi.firstatom && i < (g_mpi.firstatom + g_mpi.myatoms))
        atom->neigh[j] = neigh;
    }
  }

  return MPI_SUCCESS;
}
开发者ID:arielzn,项目名称:potfit,代码行数:30,代码来源:mpi_utils.c

示例4: switch

byte CRPlayer::_RspLianDui(byte byRspType, byte &byGrade, byte &byCount)
{
	byte byRtnType = TYPE_GVP;
	word _bitmap = 0;
	switch (byRspType)
	{
	case TYPE_GVP:
	case TYPE_LIANDUI:
		_bitmap = bitmap[1] | bitmap[2] | bitmap[3];
		_bitmap &= MASK_SHUNZI;
		_bitmap &= TblContraryMask[byGrade]; //更大的牌

		word mask;
		while (mask = TblShunZi3[_bitmap])
		{
			if (WORD_BIT_COUNT(mask) >= byCount)
			{
				byGrade = TblBitIndex[(mask & -mask) % 37];
				return TYPE_LIANDUI;
			}
			_bitmap ^= mask; //连对长度不够
		}
		byGrade = GRADE_INIT;
		byCount = 0;
	case TYPE_BOMB:
		byRtnType = _RspAnyBomb(byGrade, byCount); CHECK_RETURN(byRtnType);
		byRtnType = _RspAnyRocket(byGrade, byCount); CHECK_RETURN(byRtnType);
	}
	return TYPE_GVP;
}
开发者ID:jason-shi,项目名称:Lib4Z,代码行数:30,代码来源:RPlayerRsp.cpp

示例5: versions

result versions(const std::string &project, redmine::config &config,
                redmine::options &options, std::vector<version> &versions) {
  std::string body;
  CHECK_RETURN(http::get(
      "/projects/" + project + "/versions.json?offset=0&limit=1000000", config,
      options, body));

  auto Root = json::read(body, false);
  CHECK_JSON_TYPE(Root, json::TYPE_OBJECT);
  CHECK(options.debug, printf("%s\n", json::write(Root, "  ").c_str()));

  auto Versions = Root.object().get("versions");
  CHECK_JSON_PTR(Versions, json::TYPE_ARRAY);

  for (auto &Version : Versions->array()) {
    CHECK_JSON_TYPE(Version, json::TYPE_OBJECT);

    redmine::version version;
    CHECK_RETURN(version.init(Version.object()));

    versions.push_back(version);
  }

  return SUCCESS;
}
开发者ID:Ruyk,项目名称:redmine,代码行数:25,代码来源:version.cpp

示例6: CHECK_RETURN

char		*get_next_line(const int fd)
{
  static t_get	*g;
  static int	k = 0;

  if (k == 0)
    {
      CHECK_RETURN(g = malloc(sizeof(t_get)), NULL, NULL);
      g->j = 0;
      g->len = 0;
    }
  k = 1;
  g->count = 0;
  g->i = 0;
  if (++(g->j) >= g->len)
    {
      CHECK_RETURN(g->len = read(fd, g->buff, READ), 0, NULL);
      g->j = 0;
    }
  if (g->len  <= 0 || READ <= 0)
    return (NULL);
  CHECK_RETURN(g->str = malloc(sizeof(char) * READ + 1), NULL, NULL);
  g->str[0] = '\0';
  g->buff[g->len] = '\0';
  CHECK_RETURN(traitement(g, fd), NULL, NULL);
  tronque(g->buff, 1, g->len - (g->i - 2));
  return (g->str);
}
开发者ID:YliesC,项目名称:42sh,代码行数:28,代码来源:get_next_line.c

示例7: wwd_wifi_start_ap

/** Starts an infrastructure WiFi network
 * @param ssid      : A null terminated string containing the SSID name of the network to join
 * @param auth_type  : Authentication type:
 *                    - WICED_SECURITY_OPEN - Open Security
 *                    - WICED_SECURITY_WPA_TKIP_PSK   - WPA Security
 *                    - WICED_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
 *                    - WICED_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
 *                    - WEP security is currently unimplemented due to lack of security
 * @param security_key : A byte array containing the cleartext security key for the network
 * @param key_length   : The length of the security_key in bytes.
 * @param channel     : 802.11 Channel number
 *
 * @return    WWD_SUCCESS : if successfully creates an AP
 *            Error code  : if an error occurred
 */
wwd_result_t wwd_wifi_start_ap( wiced_ssid_t* ssid, wiced_security_t auth_type, const uint8_t* security_key, uint8_t key_length, uint8_t channel )
{
    CHECK_RETURN( wwd_wifi_ap_init( ssid, auth_type, security_key, key_length, channel ) );

    CHECK_RETURN( wwd_wifi_ap_up() );

    return WWD_SUCCESS;
}
开发者ID:humminglab,项目名称:wiced-project,代码行数:23,代码来源:wwd_ap.c

示例8: wwd_wifi_stop_ap

wwd_result_t wwd_wifi_stop_ap( void )
{
    uint32_t* data;
    wiced_buffer_t buffer;
    wiced_buffer_t response;
    wwd_result_t result;
    wwd_result_t result2;

    /* Query bss state (does it exist? if so is it UP?) */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4, IOVAR_STR_BSS );
    CHECK_IOCTL_BUFFER( data );
    *data = wwd_get_bss_index( WWD_AP_INTERFACE );
    result = wwd_sdpcm_send_iovar( SDPCM_GET, buffer, &response, WWD_STA_INTERFACE );
    if ( result == WWD_WLAN_NOTFOUND )
    {
        /* AP interface does not exist - i.e. it is down */
        wwd_wifi_ap_is_up = WICED_FALSE;
        return WWD_SUCCESS;
    }

    CHECK_RETURN( result );

    data = (uint32_t*) host_buffer_get_current_piece_data_pointer( response );
    if ( data[0] != (uint32_t) BSS_UP )
    {
        /* AP interface indicates it is not up - i.e. it is down */
        host_buffer_release( response, WWD_NETWORK_RX );
        wwd_wifi_ap_is_up = WICED_FALSE;
        return WWD_SUCCESS;
    }

    host_buffer_release( response, WWD_NETWORK_RX );

    /* set BSS down */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 8, IOVAR_STR_BSS );
    CHECK_IOCTL_BUFFER( data );
    data[0] = wwd_get_bss_index( WWD_AP_INTERFACE );
    data[1] = (uint32_t) BSS_DOWN;
    CHECK_RETURN( wwd_sdpcm_send_iovar( SDPCM_SET, buffer, 0, WWD_STA_INTERFACE ) );

    /* Wait until AP is brought down */
    result = host_rtos_get_semaphore( &wwd_wifi_sleep_flag, (uint32_t) 10000, WICED_FALSE );
    result2 = host_rtos_deinit_semaphore( &wwd_wifi_sleep_flag );
    if ( result != WWD_SUCCESS )
    {
        return result;
    }
    if ( result2 != WWD_SUCCESS )
    {
        return result2;
    }

    CHECK_RETURN( wwd_management_set_event_handler( apsta_events, NULL, NULL, WWD_AP_INTERFACE ) );

    wwd_wifi_ap_is_up = WICED_FALSE;
    return WWD_SUCCESS;

}
开发者ID:humminglab,项目名称:wiced-project,代码行数:58,代码来源:wwd_ap.c

示例9: toneport_init

/*
	 Init Toneport device.
*/
int toneport_init(struct usb_interface *interface,
		  struct usb_line6_toneport *toneport)
{
	int err, ticks;
	struct usb_line6 *line6 = &toneport->line6;
	struct usb_device *usbdev;

	if ((interface == NULL) || (toneport == NULL))
		return -ENODEV;

	/* initialize audio system: */
	err = line6_init_audio(line6);
	if (err < 0) {
		toneport_destruct(interface);
		return err;
	}

	/* initialize PCM subsystem: */
	err = line6_init_pcm(line6, &toneport_pcm_properties);
	if (err < 0) {
		toneport_destruct(interface);
		return err;
	}

	/* register audio system: */
	err = line6_register_audio(line6);
	if (err < 0) {
		toneport_destruct(interface);
		return err;
	}

	usbdev = line6->usbdev;
	line6_read_serial_number(line6, &toneport->serial_number);
	line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);

	/* sync time on device with host: */
	ticks = (int)get_seconds();
	line6_write_data(line6, 0x80c6, &ticks, 4);

	/*
	   seems to work without the first two...
	 */
	/* toneport_send_cmd(usbdev, 0x0201, 0x0002); */
	/* toneport_send_cmd(usbdev, 0x0801, 0x0000); */
	/* only one that works for me; on GP, TP might be different? */
	toneport_send_cmd(usbdev, 0x0301, 0x0000);

	if (usbdev->descriptor.idProduct != LINE6_DEVID_GUITARPORT) {
		CHECK_RETURN(device_create_file
			     (&interface->dev, &dev_attr_led_red));
		CHECK_RETURN(device_create_file
			     (&interface->dev, &dev_attr_led_green));
		toneport_update_led(&usbdev->dev);
	}

	return 0;
}
开发者ID:kapoloclubs,项目名称:diana,代码行数:60,代码来源:toneport.c

示例10: SL_ERROR

int CAppCtrl::WorkInit()
{
	///停止主循环,待Init执行完毕后再执行主循环
	m_InitFinish = false;

	//初始化数据缓冲区
	m_stClientEncodeBuf.Attach(NULL, STREAM_BUFF_LENGTH, 0);
	m_stServerEncodeBuf.Attach(NULL, STREAM_BUFF_LENGTH, 0);
	m_stClientDecodeBuf.Attach(NULL, STREAM_BUFF_LENGTH, 0);

	///初始化後台連接
	int iRet = 0;
	bool NewServer = false;
	for (size_t i = 0; i < APP_CONF->SvrConnectInfo.size(); ++i)
	{
		CSvrConnectParam& stParam = APP_CONF->SvrConnectInfo[i];
		if(stParam.Index < 0 || stParam.Index >= EMAX_SVRCONN_COUNT)
		{
			SL_ERROR("invalid svr index %d, must in[0~%d]", stParam.Index, EMAX_SVRCONN_COUNT);
			return -1;
		}

		iRet = m_SvrConnect[stParam.Index].Init(GetEpoll(), stParam);
		CHECK_RETURN(iRet);

		iRet = m_SvrConnect[stParam.Index].ConnectSvr();
		CHECK_RETURN(iRet);
	}

	//加载业务so
	/*iRet = m_stSoLoader.LoadAppSo(APP_CONF->SoPath.c_str());
	CHECK_RETURN(iRet);
	CAppSoInf* pstAppSo = m_stSoLoader.CreateAppSo();
	if(pstAppSo == NULL)
	{
		return -1;
	}*/

	//调用so的onInit
	//iRet = SL_APPSO->OnInitConfig();
	CHECK_RETURN(iRet);
	SL_TRACE("appctrl init OnInitConfig");
	
	///内存预分配
	iRet = InitAppBuffer();
	CHECK_RETURN(iRet);
	SL_TRACE("appctrl init InitAppBuffer");

	/*iRet = SL_APPSO->OnInitBuffer();
	CHECK_RETURN(iRet);
	SL_TRACE("appctrl init OnInitBuffer");*/

	iRet = m_stShmBuff.CreateBuff("key/appsvr.key");
	CHECK_RETURN(iRet);
	SL_TRACE("appctrl init CreateBuff");

}
开发者ID:killbug2004,项目名称:shyloo,代码行数:57,代码来源:appctrl.cpp

示例11: LOG

void PlanetWars::IssueOrder(int source_planet, int destination_planet, int num_ships) const
{
	LOG("IssueOrder : (%3d -> %3d) [%3d]\n", source_planet, destination_planet, num_ships);

	CHECK_RETURN(GetPlanet(source_planet).GetOwner() == 1, "Error : Bad Source Planet\n");
	CHECK_RETURN(source_planet != destination_planet, "Error : Same Planet\n");
	CHECK_RETURN(GetPlanet(source_planet).GetRealShipsCount() >= num_ships, "Error : Too many Ship (%d pour %d)\n", num_ships, GetPlanet(source_planet).GetRealShipsCount());
	CHECK_RETURN(num_ships > 0, "Error : Negative ship count\n");

	cout << source_planet << " " << destination_planet << " " << num_ships << endl;
	cout.flush();
}
开发者ID:beanhome,项目名称:dev,代码行数:12,代码来源:PlanetWars.cpp

示例12: main

int main(int argc, char* argv[]){
    int ret;
    AppContext ctx;

    ret = parseArgs(argc, argv, ctx);

    CHECK_RETURN(ret);

    ret = loadWords(ctx);
    CHECK_RETURN(ret);

    ret = process(ctx);

    return ret;
}
开发者ID:fanyunfeng,项目名称:mtools,代码行数:15,代码来源:fword.cpp

示例13: n8_initializeSSL_req

/** @ingroup n8_packet  
 * @brief Precomputes values for MD5 hashes.
 *
 *  @param cipherInfo_p        RW:  Cipher information
 *  @param packetObject_p      RO:  Pointer to packet object.  May be NULL.
 *  @param req_pp              RW:  Pointer to request pointer.
 *
 * @par Externals
 *    None
 *
 * @return
 *    Status code
 *
 * @par Errors
 *    None
 * @par Assumptions
 *    None
 *****************************************************************************/
static N8_Status_t n8_initializeSSL_req(N8_CipherInfo_t *cipherInfo_p, 
                                        N8_Packet_t  *packetObject_p,
                                        N8_Buffer_t **ctx_pp,
                                        uint32_t *ctxa_p,
                                        API_Request_t **req_pp)
{
   N8_Status_t        ret = N8_STATUS_OK; 
   API_Request_t     *req_p = NULL;

   do
   {
      CHECK_OBJECT(cipherInfo_p, ret);
      CHECK_OBJECT(packetObject_p, ret);
      /* initialize set the return request pointer to NULL.  it wil be reset
       * with an actual value later if necessary. */
      *req_pp = NULL;

      ret =
         n8_precompute_ssl_ipad_opad(packetObject_p->cipherInfo.macSecret,
                                     packetObject_p->cipherInfo.precompute1,
                                     packetObject_p->cipherInfo.precompute2);
      CHECK_RETURN(ret);

   } while (FALSE);
   /*
    * Clean up if we arrived from an error condition.
    */
   if (ret != N8_STATUS_OK)
   {
      freeRequest(req_p);
   }
   return ret;
} /* n8_initializeSSL_req */
开发者ID:NetBsdDriverProxy,项目名称:NetBsdDriverProxy,代码行数:51,代码来源:n8_packet.c

示例14: main

/// Causes an invariant failure dependent on first argument value.
/// One ignored argument is accepted to conform with the test.pl script,
/// which would be the input source file for other cbmc driver programs.
/// Returns 1 on unexpected arguments.
int main(int argc, char** argv)
{
  if(argc!=3)
    return 1;
  std::string arg=argv[1];
  if(arg=="structured")
    INVARIANT_STRUCTURED(false, structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="string")
    INVARIANT(false, "Test invariant failure");
  else if(arg=="precondition-structured")
    PRECONDITION_STRUCTURED(false, structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="precondition-string")
    PRECONDITION(false);
  else if(arg=="postcondition-structured")
    POSTCONDITION_STRUCTURED(false, structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="postcondition-string")
    POSTCONDITION(false);
  else if(arg=="check-return-structured")
    CHECK_RETURN_STRUCTURED(false, structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="check-return-string")
    CHECK_RETURN(false);
  else if(arg=="unreachable-structured")
    UNREACHABLE_STRUCTURED(structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="unreachable-string")
    UNREACHABLE;
  else if(arg=="data-invariant-structured")
    DATA_INVARIANT_STRUCTURED(false, structured_error_testt, 1, "Structured error"); // NOLINT
  else if(arg=="data-invariant-string")
    DATA_INVARIANT(false, "Test invariant failure");
  else if(arg=="irep")
    INVARIANT_WITH_IREP(false, "error with irep", pointer_type(void_typet()));
  else
    return 1;
}
开发者ID:theyoucheng,项目名称:cbmc,代码行数:38,代码来源:driver.cpp

示例15: NM_gemv

/* Numerics Matrix wrapper  for y <- alpha A x + beta y */
void NM_gemv(const double alpha, NumericsMatrix* A, const double *x,
             const double beta, double *y)
{
    switch (A->storageType)
    {
    case NM_DENSE:
    {
        cblas_dgemv(CblasColMajor, CblasNoTrans, A->size0, A->size1,
                    alpha, A->matrix0, A->size0, x, 1, beta, y, 1);

        break;
    }

    case NM_SPARSE_BLOCK:
    {
        prodSBM(A->size1, A->size0, alpha, A->matrix1, x, beta, y);

        break;
    }

    default:
    {
        assert(A->storageType == NM_SPARSE);
        CHECK_RETURN(cs_aaxpy(alpha, NM_csc(A), x, beta, y));
    }
    }
}
开发者ID:fperignon,项目名称:siconos,代码行数:28,代码来源:NumericsMatrix.c


注:本文中的CHECK_RETURN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。