chiark / gitweb /
use strneq instead of strncmp
[elogind.git] / src / udev / udev-builtin-net_id.c
index 312a54a6c1368e91954bdec6c3cabf1800897a42..c55c34d614037c53136350118bf1ef282b73326b 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
@@ -221,7 +223,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);
                 }
@@ -327,10 +329,13 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) {
         if (!bcmadev)
                 return -ENOENT;
 
-        /* bus numcore num */
+        /* bus num:core num */
         if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*d:%d", &core) != 1)
                 return -EINVAL;
-        snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core);
+        /* suppress the common core == 0 */
+        if (core > 0)
+                snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core);
+
         names->type = NET_BCMA;
         return 0;
 }