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


C++ safe_strerror函数代码示例

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


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

示例1: register_rpa_interface_table

/**gjd : register/unregister rpa table, used for local board **/
int register_rpa_interface_table(struct interface *ifp)
{
	int fd, ret;
	int flag;
	index_table_info dev_index_info;

	
	ifp->slot = get_slot_num(ifp->name);
	
	dev_index_info.slotNum = ifp->slot - 1;
	dev_index_info.netdevNum =ifp->devnum;

	/**0: not rpa dev (real interface), 1:rpa dev**/
	flag = 0;
	dev_index_info.flag = flag;
	dev_index_info.ifindex = ifp->ifindex;
	fd = open(DEV_NAME, O_RDWR);
	if(fd < 0)
	{
		zlog_warn("ioctl open error : %s .\n",safe_strerror(errno));
		return -1;
	}
		
	ret = ioctl(fd, RPA_IOC_INDEX_TABLE_ADD, &dev_index_info);
	if(ret < 0)
	{
		zlog_warn("ioctl error : %s .\n",safe_strerror(errno));
		close(fd);
		return -1;
	}

	close(fd);
	ifp->devnum = ret;/**fetch the devnum**/
	return 0;
		

}
开发者ID:kkcloudy,项目名称:daemongroup,代码行数:38,代码来源:tipc_zclient_lib.c

示例2: netlink_request

/* Get type specified information from netlink. */
static int
netlink_request (int family, int type, struct nlsock *nl)
{
  int ret;
  struct sockaddr_nl snl;
  int save_errno;

  struct
  {
    struct nlmsghdr nlh;
    struct rtgenmsg g;
  } req;


  /* Check netlink socket. */
  if (nl->sock < 0)
    {
      zlog (NULL, LOG_ERR, "%s socket isn't active.", nl->name);
      return -1;
    }

  memset (&snl, 0, sizeof snl);
  snl.nl_family = AF_NETLINK;

  memset (&req, 0, sizeof req);
  req.nlh.nlmsg_len = sizeof req;
  req.nlh.nlmsg_type = type;
  req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
  req.nlh.nlmsg_pid = nl->snl.nl_pid;
  req.nlh.nlmsg_seq = ++nl->seq;
  req.g.rtgen_family = family;

  /* linux appears to check capabilities on every message 
   * have to raise caps for every message sent
   */

  ret = sendto (nl->sock, (void *) &req, sizeof req, 0,
                (struct sockaddr *) &snl, sizeof snl);
  save_errno = errno;

  if (ret < 0)
    {
      zlog (NULL, LOG_ERR, "%s sendto failed: %s", nl->name,
            safe_strerror (save_errno));
      return -1;
    }

  return 0;
}
开发者ID:rgmabs19357,项目名称:HA,代码行数:50,代码来源:rt_netlink.c

示例3: gdb_pthread_fork

pthread_t
gdb_pthread_fork(pthread_fn_t function, void *arg)
{
  int result;
  pthread_t pthread = NULL;
  pthread_attr_t attr;

  result = pthread_attr_init(&attr);
  if (result != 0)
    {
      error("Unable to initialize thread attributes: %s (%d)",
            safe_strerror(errno), errno);
    }

  result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  if (result != 0)
    {
      error("Unable to initialize thread attributes: %s (%d)",
            safe_strerror(errno), errno);
    }

  result = pthread_create(&pthread, &attr, function, arg);
  if (result != 0)
    {
      error("Unable to create thread: %s (%d)", safe_strerror(errno), errno);
    }

  result = pthread_attr_destroy(&attr);
  if (result != 0)
    {
      warning("Unable to deallocate thread attributes: %s (%d)",
              safe_strerror(errno), errno);
    }

  return pthread;
}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:36,代码来源:macosx-nat-threads.c

示例4: x86_linux_enable_btrace

static struct btrace_target_info *
x86_linux_enable_btrace (struct target_ops *self, ptid_t ptid,
                         const struct btrace_config *conf)
{
    struct btrace_target_info *tinfo;

    errno = 0;
    tinfo = linux_enable_btrace (ptid, conf);

    if (tinfo == NULL)
        error (_("Could not enable branch tracing for %s: %s."),
               target_pid_to_str (ptid), safe_strerror (errno));

    return tinfo;
}
开发者ID:msmania,项目名称:gdb,代码行数:15,代码来源:x86-linux-nat.c

示例5: ctf_start

static void
ctf_start (struct trace_file_writer *self, const char *dirname)
{
  char *file_name;
  struct cleanup *old_chain;
  struct ctf_trace_file_writer *writer
    = (struct ctf_trace_file_writer *) self;
  int i;
  mode_t hmode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH;

  /* Create DIRNAME.  */
  if (mkdir (dirname, hmode) && errno != EEXIST)
    error (_("Unable to open directory '%s' for saving trace data (%s)"),
	   dirname, safe_strerror (errno));

  memset (&writer->tcs, '\0', sizeof (writer->tcs));

  file_name = xstrprintf ("%s/%s", dirname, CTF_METADATA_NAME);
  old_chain = make_cleanup (xfree, file_name);

  writer->tcs.metadata_fd = fopen (file_name, "w");
  if (writer->tcs.metadata_fd == NULL)
    error (_("Unable to open file '%s' for saving trace data (%s)"),
	   file_name, safe_strerror (errno));
  do_cleanups (old_chain);

  ctf_save_metadata_header (&writer->tcs);

  file_name = xstrprintf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
  old_chain = make_cleanup (xfree, file_name);
  writer->tcs.datastream_fd = fopen (file_name, "w");
  if (writer->tcs.datastream_fd == NULL)
    error (_("Unable to open file '%s' for saving trace data (%s)"),
	   file_name, safe_strerror (errno));
  do_cleanups (old_chain);
}
开发者ID:phausler,项目名称:binutils,代码行数:36,代码来源:ctf.c

示例6: ctf_save_write_metadata

static void
ctf_save_write_metadata (struct trace_write_handler *handler,
			 const char *format, ...)
{
  va_list args;

  va_start (args, format);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
  if (vfprintf (handler->metadata_fd, format, args) < 0)
    error (_("Unable to write metadata file (%s)"),
	     safe_strerror (errno));
#pragma clang diagnostic pop
  va_end (args);
}
开发者ID:phausler,项目名称:binutils,代码行数:15,代码来源:ctf.c

示例7: sockunion_socket

/* Return socket of sockunion. */
int sockunion_socket(const union sockunion *su)
{
	int sock;

	sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
	if (sock < 0) {
		char buf[SU_ADDRSTRLEN];
		zlog_warn("Can't make socket for %s : %s",
			  sockunion_log(su, buf, SU_ADDRSTRLEN),
			  safe_strerror(errno));
		return -1;
	}

	return sock;
}
开发者ID:Azure,项目名称:sonic-bcm-lkm,代码行数:16,代码来源:sockunion.c

示例8: getsockopt_so_sendbuf

int
getsockopt_so_sendbuf (const int sock)
{
  u_int32_t optval;
  socklen_t optlen = sizeof (optval);
  int ret = getsockopt (sock, SOL_SOCKET, SO_SNDBUF,
    (char *)&optval, &optlen);
  if (ret < 0)
  {
    zlog_err ("fd %d: can't getsockopt SO_SNDBUF: %d (%s)",
      sock, errno, safe_strerror (errno));
    return ret;
  }
  return optval;
}
开发者ID:millken,项目名称:zhuxianB30,代码行数:15,代码来源:sockopt.c

示例9: ospf6_recvmsg

int
ospf6_recvmsg (struct in6_addr *src, struct in6_addr *dst,
               unsigned int *ifindex, struct iovec *message)
{
  int retval;
  struct msghdr rmsghdr;
  struct cmsghdr *rcmsgp;
  u_char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
  struct in6_pktinfo *pktinfo;
  struct sockaddr_in6 src_sin6;

  rcmsgp = (struct cmsghdr *)cmsgbuf;
  pktinfo = (struct in6_pktinfo *)(CMSG_DATA(rcmsgp));
  memset (&src_sin6, 0, sizeof (struct sockaddr_in6));

  /* receive control msg */
  rcmsgp->cmsg_level = IPPROTO_IPV6;
  rcmsgp->cmsg_type = IPV6_PKTINFO;
  rcmsgp->cmsg_len = CMSG_LEN (sizeof (struct in6_pktinfo));
  /* rcmsgp = CMSG_NXTHDR (&rmsghdr, rcmsgp); */

  /* receive msg hdr */
  memset (&rmsghdr, 0, sizeof (rmsghdr));
  rmsghdr.msg_iov = message;
  rmsghdr.msg_iovlen = iov_count (message);
  rmsghdr.msg_name = (caddr_t) &src_sin6;
  rmsghdr.msg_namelen = sizeof (struct sockaddr_in6);
  rmsghdr.msg_control = (caddr_t) cmsgbuf;
  rmsghdr.msg_controllen = sizeof (cmsgbuf);

  retval = recvmsg (ospf6_sock, &rmsghdr, 0);
  if (retval < 0)
    zlog_warn ("recvmsg failed: %s", safe_strerror (errno));
  else if (retval == iov_totallen (message))
    zlog_warn ("recvmsg read full buffer size: %d", retval);

  /* source address */
  assert (src);
  memcpy (src, &src_sin6.sin6_addr, sizeof (struct in6_addr));

  /* destination address */
  if (ifindex)
    *ifindex = pktinfo->ipi6_ifindex;
  if (dst)
    memcpy (dst, &pktinfo->ipi6_addr, sizeof (struct in6_addr));

  return retval;
}
开发者ID:carriercomm,项目名称:vyatta-quagga,代码行数:48,代码来源:ospf6_network.c

示例10: ve_sub_inteface_name_check

/*gujd : 2012-08-02, pm 6:17 . Add for ve sub from ve1.100 change to ve01f1.100 .*/
int
ve_sub_inteface_name_check(const char *name, char *name_return)
{
	char name_str[64]={0};
	char *endp = NULL;
	unsigned int slot_id = 0;
	
	memcpy(name_str,name,strlen(name));

	slot_id = strtoul(name_str+2,&endp,10);/*use name_str+2, cut "ve" .*/
	if(slot_id <= 0)
	{
		zlog_warn("%s : strtoul get slot_id failed(%s).\n",__func__,safe_strerror(errno));
		return -1;
		
	}
	if(endp)
	{
		if(endp[0]=='.')/*like ve1.100*/
		{
			if(slot_id >=1 && slot_id <= 9)/*slot 1--9, add to '01, 02, ..., 09' */
			{
				sprintf(name_return,"ve0%df1%s",slot_id,endp);/*consider as first cpu, so add 'f1' .*/
				return 0;
			}
			else/* > 9*/
			{
				sprintf(name_return,"ve%df1%s",slot_id,endp);/*consider as first cpu, so add 'f1' .*/
				return 0;
			}
		}
		else if(endp[0]=='f'||endp[0]=='s')/*like ve01f1.100*/
		{
			return 1;
		}
		else
		{
			zlog_warn("%s: err parments!\n",__func__);
			return -1;
		}
			
	}
	else
		{
			return -1;
		}
	
}
开发者ID:kkcloudy,项目名称:daemongroup,代码行数:49,代码来源:tipc_zclient_lib.c

示例11: isis_recv_pdu_p2p

int
isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
{
    int bytesread;

    bytesread = stream_read (circuit->rcv_stream, circuit->fd,
                             circuit->interface->mtu);

    if (bytesread < 0)
    {
        zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", safe_strerror (errno));
        return ISIS_WARNING;
    }

    return ISIS_OK;
}
开发者ID:kkcloudy,项目名称:daemongroup,代码行数:16,代码来源:isis_network.c

示例12: if_get_flags

/* get interface flags */
void if_get_flags (struct interface *ifp)
{
	int ret = 0;
	struct ifreq ifreq;

	ifreq_set_name (&ifreq, ifp);

	ret = if_ioctl (SIOCGIFFLAGS, (caddr_t) &ifreq);
	if (ret < 0)
	{
		zlog_err("if_ioctl(SIOCGIFFLAGS) failed: %s", safe_strerror(errno));
		return;
	}

	if_flags_update (ifp, (ifreq.ifr_flags & 0x0000ffff));
}
开发者ID:millken,项目名称:zhuxianB30,代码行数:17,代码来源:ioctl.c

示例13: pim_time_monotonic_dsec

/*
  pim_time_monotonic_dsec():
  number of deciseconds since some unspecified starting point
*/
int64_t pim_time_monotonic_dsec()
{
  struct timeval now_tv;
  int64_t        now_dsec;

  if (gettime_monotonic(&now_tv)) {
    zlog_err("%s: gettime_monotonic() failure: errno=%d: %s",
	     __PRETTY_FUNCTION__,
	     errno, safe_strerror(errno));
    return -1;
  }

  now_dsec = ((int64_t) now_tv.tv_sec) * 10 + ((int64_t) now_tv.tv_usec) / 100000;

  return now_dsec;
}
开发者ID:AT-Corp,项目名称:quagga-atc,代码行数:20,代码来源:pim_time.c

示例14: safe_write

int ShiftWriter::Write(void* buf, int len)
{
    int ret = safe_write(_fd, buf, static_cast<size_t>(len));
    if (ret < 0) {
        _errmsg = safe_strerror(errno);
    }

    _cur_file_size += len;
    // shift最好放在后边,这样如果刚好写完一个文件,就会生成另一个文件
    // 否则可能会看到没有log主文件
    if (_cur_file_size > _max_file_size && !Shift()) {
        return -1;
    }

    return ret;
}
开发者ID:keynumber,项目名称:tmp,代码行数:16,代码来源:shift_writer.cpp

示例15: ospf6_sso

/* ospf6 set socket option */
void
ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
{
  struct ipv6_mreq mreq6;
  int ret;

  assert (ifindex);
  mreq6.ipv6mr_interface = ifindex;
  memcpy (&mreq6.ipv6mr_multiaddr, group, sizeof (struct in6_addr));

  ret = setsockopt (ospf6_sock, IPPROTO_IPV6, option,
                    &mreq6, sizeof (mreq6));
  if (ret < 0)
    zlog_err ("Network: setsockopt (%d) on ifindex %d failed: %s",
              option, ifindex, safe_strerror (errno));
}
开发者ID:Balaji-Parasuram,项目名称:quagga,代码行数:17,代码来源:ospf6_network.c


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