From: Guus Sliepen Date: Fri, 7 May 2010 10:24:49 +0000 (+0200) Subject: Use strrchr() insteaad of rindex(). X-Git-Tag: release-1.0.14~50 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=dbf3d168b720045328d476f3b9e5f5e45b4ab6de;p=tinc Use strrchr() insteaad of rindex(). The latter function is deprecated, some build environments do not support. --- diff --git a/src/bsd/device.c b/src/bsd/device.c index c2cd34cb..6674abd2 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -64,7 +64,7 @@ bool setup_device(void) { device = xstrdup(DEFAULT_DEVICE); if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) - iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device); + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) { if(!strcasecmp(type, "tun")) diff --git a/src/linux/device.c b/src/linux/device.c index 35c66d55..6363b126 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -61,7 +61,7 @@ bool setup_device(void) { if (netname != NULL) iface = xstrdup(netname); #else - iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device); + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); #endif device_fd = open(device, O_RDWR | O_NONBLOCK); @@ -105,7 +105,7 @@ bool setup_device(void) { device_type = DEVICE_TYPE_ETHERTAP; if(iface) free(iface); - iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device); + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); } logger(LOG_INFO, "%s is a %s", device, device_info);