Use strrchr() insteaad of rindex().
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 7 May 2010 10:24:49 +0000 (12:24 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 7 May 2010 10:24:49 +0000 (12:24 +0200)
The latter function is deprecated, some build environments do not support.

src/bsd/device.c
src/linux/device.c

index c2cd34cb4af14f4e6fdc019c54b0d6c883984607..6674abd209a23aa7763073097081114e263431ee 100644 (file)
@@ -64,7 +64,7 @@ bool setup_device(void) {
                device = xstrdup(DEFAULT_DEVICE);
 
        if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
                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"))
 
        if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) {
                if(!strcasecmp(type, "tun"))
index 35c66d55a44ddad0155576cba8f5a9e9a49b6777..6363b126c3d9c4643ff5da7ccfd2d80ebc8c1c81 100644 (file)
@@ -61,7 +61,7 @@ bool setup_device(void) {
                if (netname != NULL)
                        iface = xstrdup(netname);
 #else
                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);
 
 #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);
                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);
        }
 
        logger(LOG_INFO, "%s is a %s", device, device_info);