mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-20 14:29:55 +02:00
cansequence: cleanup perror() and exit()
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
+7
-7
@@ -265,27 +265,27 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
s = socket(family, type, proto);
|
s = socket(family, type, proto);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
perror("socket");
|
perror("socket()");
|
||||||
return 1;
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
addr.can_family = family;
|
addr.can_family = family;
|
||||||
strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
|
strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
|
||||||
if (ioctl(s, SIOCGIFINDEX, &ifr)) {
|
if (ioctl(s, SIOCGIFINDEX, &ifr)) {
|
||||||
perror("ioctl");
|
perror("ioctl()");
|
||||||
return 1;
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
addr.can_ifindex = ifr.ifr_ifindex;
|
addr.can_ifindex = ifr.ifr_ifindex;
|
||||||
|
|
||||||
/* first don't recv. any msgs */
|
/* first don't recv. any msgs */
|
||||||
if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0)) {
|
if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0)) {
|
||||||
perror("setsockopt");
|
perror("setsockopt()");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||||
perror("bind");
|
perror("bind()");
|
||||||
return 1;
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receive)
|
if (receive)
|
||||||
|
|||||||
Reference in New Issue
Block a user