Compare commits

..

3 Commits

Author SHA1 Message Date
GGZ8 c65e93df49
Merge 7815be8741 into 287469245c 2025-04-09 05:30:13 -04:00
Marc Kleine-Budde 287469245c
Merge pull request #123 from twasilczyk/slcand-android
Don't fail when it wasn't possible to fetch the interface name.
2025-04-06 10:11:38 +02:00
Tomasz Wasilczyk 7a318636e7 slcand: Don't fail when it wasn't possible to fetch the interface name.
On some systems SIOCGIFNAME may fail with ENOTTY, but the actual
slcanX interface gets properly configured. Instead of crashing hard on
such case, let's gracefuly degrade and just not display the interface
name.
2025-04-06 10:03:36 +02:00
1 changed files with 7 additions and 2 deletions

View File

@ -370,8 +370,13 @@ int main(int argc, char *argv[])
/* retrieve the name of the created CAN netdevice */
if (ioctl(fd, SIOCGIFNAME, ifr.ifr_name) < 0) {
perror("ioctl SIOCGIFNAME");
exit(EXIT_FAILURE);
if (name) {
perror("ioctl SIOCGIFNAME");
exit(EXIT_FAILURE);
} else {
/* Graceful degradation: we only needed the name for display. */
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "<unknown>");
}
}
syslogger(LOG_NOTICE, "attached TTY %s to netdevice %s\n", ttypath, ifr.ifr_name);