X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fudev%2Fudev-builtin-net_id.c;h=b91ca9df5b4e748da45f9237bce8f3e3a8a25503;hb=b5dd8148730db080b48b874c214f8f74ae787d6b;hp=5b732bb418e7d894d867cc2dff50616cc6b2da87;hpb=214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7;p=elogind.git diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 5b732bb41..b91ca9df5 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -159,30 +159,24 @@ static bool is_pci_multifunction(struct udev_device *dev) { if ((config[PCI_HEADER_TYPE] & 0x80) != 0) multi = true; out: - if(f) + if (f) fclose(f); return multi; } static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { struct udev *udev = udev_device_get_udev(names->pcidev); - unsigned int domain; - unsigned int bus; - unsigned int slot; - unsigned int func; - unsigned int dev_id = 0; + unsigned domain, bus, slot, func, dev_id = 0; size_t l; char *s; const char *attr; struct udev_device *pci = NULL; - char slots[256]; - DIR *dir; + char slots[256], str[256]; + _cleanup_closedir_ DIR *dir = NULL; struct dirent *dent; - char str[256]; - int hotplug_slot = 0; - int err = 0; + int hotplug_slot = 0, err = 0; - if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%d", &domain, &bus, &slot, &func) != 4) + if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4) return -ENOENT; /* kernel provided multi-device index */ @@ -239,7 +233,6 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { if (hotplug_slot > 0) break; } - closedir(dir); if (hotplug_slot > 0) { s = names->pci_slot; @@ -341,11 +334,11 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) { return -ENOENT; /* bus num:core num */ - if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*d:%d", &core) != 1) + if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*u:%u", &core) != 1) return -EINVAL; /* suppress the common core == 0 */ if (core > 0) - snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core); + snprintf(names->bcma_core, sizeof(names->bcma_core), "b%u", core); names->type = NET_BCMA; return 0; @@ -396,7 +389,7 @@ static int ieee_oui(struct udev_device *dev, struct netnames *names, bool test) snprintf(str, sizeof(str), "OUI:%02X%02X%02X%02X%02X%02X", names->mac[0], names->mac[1], names->mac[2], names->mac[3], names->mac[4], names->mac[5]); - udev_builtin_hwdb_lookup(dev, str, test); + udev_builtin_hwdb_lookup(dev, NULL, str, NULL, test); return 0; }