mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-06 06:49:53 +02:00
Merge pull request #244 from marckleinebudde/canfdtest-check-device
canfdtest: bail out if trying to use non-existing CAN interface
This commit is contained in:
@@ -422,6 +422,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
addr.can_family = family;
|
addr.can_family = family;
|
||||||
addr.can_ifindex = if_nametoindex(intf_name);
|
addr.can_ifindex = if_nametoindex(intf_name);
|
||||||
|
if (!addr.can_ifindex) {
|
||||||
|
perror("if_nametoindex");
|
||||||
|
close(sockfd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
|
|||||||
Reference in New Issue
Block a user