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


C++ p_err函数代码示例

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


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

示例1: msgfree

int msgfree(msg_q_t msgid)
{
	int i;
	INT8U perr;

	for (i = 0; i < OS_MAX_QS; i++)
	{
		if (q_man[i].msg == msgid)
			break;
	}
	if (i >= OS_MAX_QS)
	{
		p_err("msgfree: err no match msg_q %x", msgid);
		return  - 1;
	}

	OSQDel((OS_EVENT*)msgid, OS_DEL_ALWAYS, &perr);
	if (OS_ERR_NONE != perr)
	{
		p_err("msgfree: free err %d", perr);
		return  - 1;
	}

	if (!q_man[i].q_start)
	{
		assert(0);
	}

	mem_free(q_man[i].q_start);
	q_man[i].q_start = 0;
	q_man[i].msg = 0;

	return 0;
}
开发者ID:foxwolf,项目名称:yjd,代码行数:34,代码来源:msg_q.c

示例2: query_flow_dissector

static int query_flow_dissector(struct bpf_attach_info *attach_info)
{
	__u32 attach_flags;
	__u32 prog_ids[1];
	__u32 prog_cnt;
	int err;
	int fd;

	fd = open("/proc/self/ns/net", O_RDONLY);
	if (fd < 0) {
		p_err("can't open /proc/self/ns/net: %d",
		      strerror(errno));
		return -1;
	}
	prog_cnt = ARRAY_SIZE(prog_ids);
	err = bpf_prog_query(fd, BPF_FLOW_DISSECTOR, 0,
			     &attach_flags, prog_ids, &prog_cnt);
	close(fd);
	if (err) {
		if (errno == EINVAL) {
			/* Older kernel's don't support querying
			 * flow dissector programs.
			 */
			errno = 0;
			return 0;
		}
		p_err("can't query prog: %s", strerror(errno));
		return -1;
	}

	if (prog_cnt == 1)
		attach_info->flow_dissector_id = prog_ids[0];

	return 0;
}
开发者ID:avagin,项目名称:linux,代码行数:35,代码来源:net.c

示例3: msgrcv

int msgrcv(msg_q_t msgid, void **msgbuf, unsigned int timeout)
{
	INT8U perr;

	if (0 == msgid)
	{
		p_err("msgrcv: msgid err");
		return  - 1;
	}

	if ((timeout > 0) && (timeout < 1000uL / OS_TICKS_PER_SEC))
		timeout = 1000uL / OS_TICKS_PER_SEC;

	timeout = timeout * OS_TICKS_PER_SEC / 1000uL;

	*msgbuf = OSQPend((OS_EVENT*)msgid, (INT32U)timeout, &perr);

	if (perr == OS_ERR_NONE)
		return 0;
	else if (perr == OS_ERR_TIMEOUT)
		return 1;

	p_err("msgrcv: err %d", perr);
	return  - 1;
}
开发者ID:foxwolf,项目名称:yjd,代码行数:25,代码来源:msg_q.c

示例4: main

int main()
{
	int ret;
	//环境初始化
	inittest();
	ret = syn_init();
	p_err(ret);
	ret = syn_rwlock_init(2);
	p_err(ret);

	//测试用例1
	ret = syn_rwlock_destroy(2);
	assert(ret == 0,"syn_rwlock_destroy Use Case 1 error");

	//测试用例2
	ret = syn_rwlock_init(2);
	p_err(ret);
	ret = syn_rwlock_destroy(64);
	assert(ret == -ERR_INVAL,"syn_rwlock_destroy Use Case 2 error");

	//测试用例3
	ret = syn_rwlock_destroy(4);
	assert(ret == -ERR_NOINIT,"syn_rwlock_destroy Use Case 3 error");

	//测试用例4
	ret = syn_rwlock_rd(2,SYN_RECV_BLOCK);
	p_err(ret);
	ret = syn_rwlock_destroy(2);
	assert(ret == -ERR_BUSY,"syn_rwlock_destroy Use Case 4 error");

	finaltest();
	return 0;
}
开发者ID:caicry,项目名称:sge800,代码行数:33,代码来源:c-xt-syn-rwlockdestroy.c

示例5: map_parse_fd

int map_parse_fd(int *argc, char ***argv)
{
	int fd;

	if (is_prefix(**argv, "id")) {
		unsigned int id;
		char *endptr;

		NEXT_ARGP();

		id = strtoul(**argv, &endptr, 0);
		if (*endptr) {
			p_err("can't parse %s as ID", **argv);
			return -1;
		}
		NEXT_ARGP();

		fd = bpf_map_get_fd_by_id(id);
		if (fd < 0)
			p_err("get map by id (%u): %s", id, strerror(errno));
		return fd;
	} else if (is_prefix(**argv, "pinned")) {
		char *path;

		NEXT_ARGP();

		path = **argv;
		NEXT_ARGP();

		return open_obj_pinned_any(path, BPF_OBJ_MAP);
	}

	p_err("expected 'id' or 'pinned', got: '%s'?", **argv);
	return -1;
}
开发者ID:avagin,项目名称:linux,代码行数:35,代码来源:map.c

示例6: do_attach

static int do_attach(int argc, char **argv)
{
	enum bpf_attach_type attach_type;
	int cgroup_fd, prog_fd;
	int attach_flags = 0;
	int ret = -1;
	int i;

	if (argc < 4) {
		p_err("too few parameters for cgroup attach");
		goto exit;
	}

	cgroup_fd = open(argv[0], O_RDONLY);
	if (cgroup_fd < 0) {
		p_err("can't open cgroup %s", argv[1]);
		goto exit;
	}

	attach_type = parse_attach_type(argv[1]);
	if (attach_type == __MAX_BPF_ATTACH_TYPE) {
		p_err("invalid attach type");
		goto exit_cgroup;
	}

	argc -= 2;
	argv = &argv[2];
	prog_fd = prog_parse_fd(&argc, &argv);
	if (prog_fd < 0)
		goto exit_cgroup;

	for (i = 0; i < argc; i++) {
		if (is_prefix(argv[i], "multi")) {
			attach_flags |= BPF_F_ALLOW_MULTI;
		} else if (is_prefix(argv[i], "override")) {
			attach_flags |= BPF_F_ALLOW_OVERRIDE;
		} else {
			p_err("unknown option: %s", argv[i]);
			goto exit_cgroup;
		}
	}

	if (bpf_prog_attach(prog_fd, cgroup_fd, attach_type, attach_flags)) {
		p_err("failed to attach program");
		goto exit_prog;
	}

	if (json_output)
		jsonw_null(json_wtr);

	ret = 0;

exit_prog:
	close(prog_fd);
exit_cgroup:
	close(cgroup_fd);
exit:
	return ret;
}
开发者ID:avagin,项目名称:linux,代码行数:59,代码来源:cgroup.c

示例7: load_tsin_db0

void load_tsin_db0(char *infname, gboolean is_gtab_i)
{
  char tsidxfname[512];
//  dbg("cur %s %s\n", infname, current_tsin_fname);

  if (current_tsin_fname && !strcmp(current_tsin_fname, infname))
    return;

  strcpy(tsidxfname, infname);
  strcat(tsidxfname, ".idx");

//  dbg("tsidxfname %s\n", tsidxfname);

  FILE *fr;

  if ((fr=fopen(tsidxfname,"rb+"))==NULL) {
    p_err("load_tsin_db0 A Cannot open '%s'\n", tsidxfname);
  }


  fread(&phcount,4,1,fr);
#if     0
  printf("phcount:%d\n",phcount);
#endif
  a_phcount=phcount+256;
  fread(&hashidx,1,sizeof(hashidx),fr);

  fp_phidx = fr;

  if (fph)
    fclose(fph);

  dbg("tsfname: %s\n", infname);

  if ((fph=fopen(infname,"rb+"))==NULL)
    p_err("load_tsin_db0 B Cannot open '%s'", infname);

  free(current_tsin_fname);
  current_tsin_fname = strdup(infname);

  if (is_gtab_i) {
    TSIN_GTAB_HEAD head;
    fread(&head, sizeof(head), 1, fph);
    if (head.keybits*head.maxkey > 32) {
      ph_key_sz = 8;
      tsin_hash_shift = TSIN_HASH_SHIFT_64;
    }
    else {
      ph_key_sz = 4;
      tsin_hash_shift = TSIN_HASH_SHIFT_32;
    }
  } else {
    ph_key_sz = 2;
    tsin_hash_shift = TSIN_HASH_SHIFT;
  }
  tsin_is_gtab = is_gtab_i;
}
开发者ID:Tetralet,项目名称:hime,代码行数:57,代码来源:tsin-util.c

示例8: get_page

void get_page(struct page *page)
{
	p_dbg_enter;
	if (page->addr)
		p_err("addr != 0\n");

	page->addr = (char*)mem_malloc(4096);
	if (!page->addr)
		p_err("no mem\n");
	g_skb_alloc_size += 4096;
} 
开发者ID:foxwolf,项目名称:yjd,代码行数:11,代码来源:skbuff.c

示例9: printf

FILE *init_tedrc_fname(char *ftedrc, int depth)
{
FILE *fp;
char tt[256],uu[256];
#if	0
printf(" %d %s\n",depth, ftedrc);
#endif
if (cdtedrc && (fp=fopen(ftedrc,"r"))) {
	return fp;
}


if (fp=fopen(
	strcat(strcat(strcpy(tt,(char *)getenv("HOME")),"/.Ted/"),ftedrc), "r"
)) 	return fp;
if (fp=fopen(strcat(strcat(strcpy(uu, TEDDIR),"/"),ftedrc),"r"))
	return fp;
if (!depth) {
  FILE *tfp;
  extern char *exec_name;
  static char exepath[128];
  int l;

  if (exepath[0]) {
    strcpy(tt,exepath);
  } else {
    sprintf(tt,"which %s",exec_name);
    if ((tfp=popen(tt,"r"))==NULL)
      p_err("cannot locate exec %s path",exec_name);
    fgets(tt,sizeof(tt),tfp);
    if ((l=strlen(tt))>0) {
      int i=l-1;
      while (i>=0 && tt[i]!='/') i--;
      if (i>=0) tt[i]=0;
      strcpy(exepath,tt);
    }
  }
  if (fp=fopen(strcat(strcat(strcpy(uu, tt),"/"),ftedrc),"r"))
    return fp;
  if ((l=strlen(tt))>0) {
    int i=l-1;
    while (i>=0 && tt[i]!='/') i--;
    if (i>=0) tt[i]=0;
    strcat(tt,"/Ted");
    if (fp=fopen(strcat(strcat(strcpy(uu, tt),"/"),ftedrc),"r"))
      return fp;
  }
	if (cdtedrc)
		p_err("Cannot find ./%s or %s or %s",ftedrc,tt,uu);
	else
		p_err("Cannot find %s or %s",ftedrc,tt,uu);
}
return fp;
}
开发者ID:8l,项目名称:ted,代码行数:54,代码来源:xkey.c

示例10: main

int main()
{
  FILE *fp;
  char fnamein[]="pin-juyin.src";
  PIN_JUYIN pinju[1024];
  short pinjuN=0;

  if ((fp=fopen(fnamein, "r"))==NULL)
    p_err("cannot open %s", fnamein);

  while (!feof(fp)) {
    char tt[128];

    tt[0]=0;
    fgets(tt, sizeof(tt), fp);
    if (strlen(tt) < 3)
      break;

    char pin[16], ju[64];
    bzero(pin, sizeof(pin));
    sscanf(tt, "%s %s",pin, ju);

    phokey_t kk=0;
    int len = strlen(ju);
    int i=0;
    while (i<len) {
      kk |= lookup((u_char *)&ju[i]);
      i+=utf8_sz(&ju[i]);
    }

//    dbg("%s '%s' %d\n", pin, ju, kk);

    memcpy(pinju[pinjuN].pinyin, pin, sizeof(pinju[0].pinyin));
    pinju[pinjuN].key = kk;
    pinjuN++;
  }

  fclose(fp);
  dbg("zz pinjuN:%d\n", pinjuN);
  
  qsort(pinju, pinjuN, sizeof(PIN_JUYIN), qcmp_str);

  char fnameout[]="pin-juyin.xlt";

  if ((fp=fopen(fnameout, "wb"))==NULL)
    p_err("cannot create %s", fnameout);

  fwrite(&pinjuN, sizeof(pinjuN), 1, fp);
  fwrite(pinju, sizeof(PIN_JUYIN), pinjuN, fp);
  fclose(fp);

  return 0;
}
开发者ID:RJHsiao,项目名称:gcin-debian,代码行数:53,代码来源:pin-juyin.cpp

示例11: USB_OTG_USBH_handle_nptxfempty_ISR

static uint32_t USB_OTG_USBH_handle_nptxfempty_ISR(USB_OTG_CORE_HANDLE*pdev)
{
	USB_OTG_GINTMSK_TypeDef intmsk;
	USB_OTG_HNPTXSTS_TypeDef hnptxsts;
	uint16_t len_words, len;

	hnptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->HNPTXSTS);
	
	#ifdef DEBUG
	if (hnptxsts.b.chnum > 0)
		p_err("nptxfempty:%d\n", hnptxsts.b.nptxfspcavail);

	if (pdev->host.hc[hnptxsts.b.chnum].xfer_len == 0)
	{
		p_err("%s xfer_len == 0, %d\n", __FUNCTION__, hnptxsts.b.chnum);
		USB_OTG_HC_Halt(pdev, hnptxsts.b.chnum); //test
		return 0;
	}
	#endif

	

	len_words = (pdev->host.hc[hnptxsts.b.chnum].xfer_len + 3) / 4;

	while ((hnptxsts.b.nptxfspcavail > len_words) && (pdev
	->host.hc[hnptxsts.b.chnum].xfer_len != 0))
	{

		len = hnptxsts.b.nptxfspcavail * 4;

		if (len > pdev->host.hc[hnptxsts.b.chnum].xfer_len)
		{
			/* Last packet */
			len = pdev->host.hc[hnptxsts.b.chnum].xfer_len;

			intmsk.d32 = 0;
			intmsk.b.nptxfempty = 1;
			USB_OTG_MODIFY_REG32(&pdev->regs.GREGS->GINTMSK, intmsk.d32, 0);
		}

		len_words = (pdev->host.hc[hnptxsts.b.chnum].xfer_len + 3) / 4;

		USB_OTG_WritePacket(pdev, pdev->host.hc[hnptxsts.b.chnum].xfer_buff,
	hnptxsts.b.chnum, len);

		pdev->host.hc[hnptxsts.b.chnum].xfer_buff += len;
		pdev->host.hc[hnptxsts.b.chnum].xfer_len -= len;
		pdev->host.hc[hnptxsts.b.chnum].xfer_count += len;
		hnptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->HNPTXSTS);
	}

	return 1;
}
开发者ID:glocklueng,项目名称:MCU_WIFI,代码行数:53,代码来源:usb_hcd_int.c

示例12: init_tcp

int init_tcp()
{
struct sockaddr_in serv_addr;

bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr=inet_addr("167.170.27.6");
serv_addr.sin_port = htons(9001);
if ((sockfd=socket(AF_INET, SOCK_STREAM, 0)) < 0)
	p_err("Cannot open socket : %s",strerror(errno));
if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
	p_err("Cannot connect : %s",strerror(errno));
}
开发者ID:gitpan,项目名称:DBD-NET,代码行数:13,代码来源:cl.c

示例13: do_show_tree

static int do_show_tree(int argc, char **argv)
{
	char *cgroup_root;
	int ret;

	switch (argc) {
	case 0:
		cgroup_root = find_cgroup_root();
		if (!cgroup_root) {
			p_err("cgroup v2 isn't mounted");
			return -1;
		}
		break;
	case 1:
		cgroup_root = argv[0];
		break;
	default:
		p_err("too many parameters for cgroup tree");
		return -1;
	}


	if (json_output)
		jsonw_start_array(json_wtr);
	else
		printf("%s\n"
		       "%-8s %-15s %-15s %-15s\n",
		       "CgroupPath",
		       "ID", "AttachType", "AttachFlags", "Name");

	switch (nftw(cgroup_root, do_show_tree_fn, 1024, FTW_MOUNT)) {
	case NFTW_ERR:
		p_err("can't iterate over %s: %s", cgroup_root,
		      strerror(errno));
		ret = -1;
		break;
	case SHOW_TREE_FN_ERR:
		ret = -1;
		break;
	default:
		ret = 0;
	}

	if (json_output)
		jsonw_end_array(json_wtr);

	if (argc == 0)
		free(cgroup_root);

	return ret;
}
开发者ID:avagin,项目名称:linux,代码行数:51,代码来源:cgroup.c

示例14: main

int main(int argc, char *argv[])
{
  struct sockaddr_in addr;
  struct hostent *host;
  int sockfd;
  char buf[1024];
  int ret;
  unsigned int optval = 1;

  if(argc != 2) {
    printf("usage: %s SERVER_NAME\n", argv[0]);
    exit(1);
  }

  /* make socket */
  if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    p_err("socket");
  printf("socket: Success\n");

  /* setsockopt */
  if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0)
    p_err("setsockopt");
  printf("setsockopt: Success\n");

  /* clear s_addr */
  bzero((char *)&addr, sizeof(addr));

  /* set socket */
  if((host = gethostbyname(argv[1])) == NULL)
    p_err("gethostbyname");
  bcopy(host->h_addr, &addr.sin_addr, host->h_length);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(PORT);

  /* connect server */
  if(connect(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
    p_err("connect");
  printf("connect: Success\n");

  /* data send */
  while(fgets(buf, 1024, stdin)) {
    write(sockfd, buf, 1024);
    ret = read(sockfd, buf, ret);
    printf("-> %s", buf);
  }
  close(sockfd);
  exit(EXIT_SUCCESS);

  return(0);
}
开发者ID:kshimo69,项目名称:tools,代码行数:50,代码来源:tcp_client_keepalive.c

示例15: connect_ts_share_svr

int connect_ts_share_svr()
{
    SOCKET ConnectSocket = -1;
    struct addrinfo *result = NULL, *ptr = NULL, hints;
    int iResult;

    bzero( &hints, sizeof(hints) );
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;

    char port_s[8];
    sprintf(port_s, "%d", TS_SHARE_SERVER_PORT);

    iResult = getaddrinfo(TS_SHARE_SERVER, port_s, &hints, &result);
    if ( iResult != 0 ) {
#if UNIX
        p_err("getaddrinfo failed: %s\n", sys_err_strA());
#else
		p_err("getaddrinfo failed: %s\n", sock_err_strA());
#endif
    }

    for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
        // Create a SOCKET for connecting to server
        ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
        if (ConnectSocket < 0) {
            dbg("Error at socket(): %s\n", sys_err_strA());
            continue;
        }

        // Connect to server.
        iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
        if (iResult < 0) {
            closesocket(ConnectSocket);
            ConnectSocket = -1;
            continue;
        }
        break;
    }

    if (ConnectSocket <= 0) {
      p_err("cannot connect to %s:%d", TS_SHARE_SERVER, TS_SHARE_SERVER_PORT, sys_err_strA());
    }

    freeaddrinfo(result);
    return ConnectSocket;
}
开发者ID:RJHsiao,项目名称:gcin-debian,代码行数:48,代码来源:ts-upload.cpp


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