add ioctl checks
This commit is contained in:
parent
1993006247
commit
7dad14fa4e
@ -397,7 +397,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
fcntl(soc, F_SETFL, O_NONBLOCK);
|
||||
strcpy(ifr.ifr_name, "can0");
|
||||
ioctl(soc, SIOCGIFINDEX, &ifr);
|
||||
if (ioctl(soc, SIOCGIFINDEX, &ifr) < 0) {
|
||||
perror("ioctl error");
|
||||
return 1;
|
||||
}
|
||||
addr.can_family = AF_CAN;
|
||||
addr.can_ifindex = ifr.ifr_ifindex;
|
||||
if (bind(soc, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user