Make sure realname is always initialized.
This commit is contained in:
parent
c87a77b5fd
commit
2b4c0c6362
1 changed files with 6 additions and 5 deletions
|
|
@ -198,18 +198,19 @@ static bool setup_device(void) {
|
||||||
|
|
||||||
// Guess what the corresponding interface is called
|
// Guess what the corresponding interface is called
|
||||||
|
|
||||||
char *realname;
|
char *realname = NULL;
|
||||||
|
|
||||||
#if defined(HAVE_FDEVNAME)
|
#if defined(HAVE_FDEVNAME)
|
||||||
realname = fdevname(device_fd) ? : device;
|
realname = fdevname(device_fd);
|
||||||
#elif defined(HAVE_DEVNAME)
|
#elif defined(HAVE_DEVNAME)
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if(!fstat(device_fd, &buf))
|
if(!fstat(device_fd, &buf))
|
||||||
realname = devname(buf.st_rdev, S_IFCHR) ? : device;
|
realname = devname(buf.st_rdev, S_IFCHR);
|
||||||
#else
|
|
||||||
realname = device;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(!realname)
|
||||||
|
realname = device;
|
||||||
|
|
||||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||||
iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname);
|
iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname);
|
||||||
else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname))
|
else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue