chiark / gitweb /
udev: fix segfault with android rndis
[elogind.git] / src / udev / udev-builtin-net_id.c
index 20d96e041daeca265e8fc3e19f462388ce931928..fdbec5ae916872b7ba380355493f850cf41091b4 100644 (file)
@@ -24,6 +24,8 @@
  *  - physical/geographical location of the hardware
  *  - the interface's MAC address
  *
+ * http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
+ *
  * Two character prefixes based on the type of interface:
  *   en -- ethernet
  *   wl -- wlan
@@ -89,6 +91,7 @@
 #include <linux/pci_regs.h>
 
 #include "udev.h"
+#include "fileio.h"
 
 enum netname_type{
         NET_UNDEF,
@@ -221,7 +224,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
                 snprintf(str, sizeof(str), "%s/%s/address", slots, dent->d_name);
                 if (read_one_line_file(str, &address) >= 0) {
                         /* match slot address with device by stripping the function */
-                        if (strncmp(address, udev_device_get_sysname(names->pcidev), strlen(address)) == 0)
+                        if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address)))
                                 hotplug_slot = i;
                         free(address);
                 }
@@ -253,7 +256,7 @@ static int names_pci(struct udev_device *dev, struct netnames *names) {
         if (!parent)
                 return -ENOENT;
         /* check if our direct parent is a PCI device with no other bus in-between */
-        if (streq("pci", udev_device_get_subsystem(parent))) {
+        if (streq_ptr("pci", udev_device_get_subsystem(parent))) {
                 names->type = NET_PCI;
                 names->pcidev = parent;
         } else {
@@ -411,7 +414,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
         p = udev_device_get_sysattr_value(dev, "iflink");
         if (!p)
                 return EXIT_FAILURE;
-        if (strcmp(s, p) != 0)
+        if (!streq(s, p))
                 return 0;
 
         devtype = udev_device_get_devtype(dev);