换了个编译环境突然报了个警告
warning: assignment from incompatible pointer type
regd_aids = ioctl_buf;
这能忍?
unsigned char ioctl_buf[4096] = {0};
int v2x_ioctl(int sk, int cnt)
{
struct register_aids reg_aids;
int ret = 0;
int *regd_aids = NULL;
unsigned long long utc;
unsigned int psn;
unsigned int psn_delay[2] = {0};
ret = ioctl(sk, GETREGDAIDSCNT, ®_aids);
printf("ioctl[%d] GETREGDAIDSCNT ret %d, cnt %d\n", cnt, ret, reg_aids.cnt);
#if 0
regd_aids = calloc(1, (cnt+1)*sizeof(int));
#else
memset(ioctl_buf, 0, sizeof(ioctl_buf));
regd_aids = ioctl_buf;
#endif
if (regd_aids) {
ret = ioctl(sk, GETREGDAIDS, regd_aids);
printf("ioctl[%d] GETREGDAIDS ret %d, cnt %d\n", cnt, ret, regd_aids[0]);
#if 0
free(regd_aids);
#endif
} else {
printf("ioctl[%d] GETREGDAIDS calloc failed\n", cnt);
}
ret = ioctl(sk, GETLASTPSN, &psn);
printf("ioctl[%d] GETLASTPSN ret %d, psn %u\n", cnt, ret, psn);
ret = ioctl(sk, GETLASTUTC, &utc);
printf("ioctl[%d] GETLASTUTC ret %d, utc %llu\n", cnt, ret, utc);
ret = ioctl(sk, GETLASTXMITEDPSN, &psn);
printf("ioctl[%d] GETLASTXMITEDPSN ret %d, psn %u\n", cnt, ret, psn);
ret = ioctl(sk, GETLASTXMITEDUTC, &utc);
printf("ioctl[%d] GETLASTXMITEDUTC ret %d, utc %llu\n", cnt, ret, utc);
ret = ioctl(sk, GETNEXTPSN, &psn);
printf("ioctl[%d] GETNEXTPSN ret %d, psn %u\n", cnt, ret, psn);
ret = ioctl(sk, GETLASTPSNDELAY, psn_delay);
printf("ioctl[%d] GETLASTPSNDELAY ret %d, psn %u, delay %uus\n", cnt, ret, psn_delay[0], psn_delay[1]);
return 0;
}
regd_aids = (int *)ioctl_buf,加个强转即可