Skip to content

Commit f831aef

Browse files
committed
udev-builtin-net_id: drop redundant copy of BCMA identifier in names_bcma()
Then, this makes names based on the BCMA and PCI identifiers in names_bcma(). No functional change, just refactoring.
1 parent d352381 commit f831aef

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/udev/udev-builtin-net_id.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
typedef enum NetNameType {
4747
NET_UNDEF,
4848
NET_PCI,
49-
NET_BCMA,
5049
} NetNameType;
5150

5251
typedef struct NetNames {
@@ -57,8 +56,6 @@ typedef struct NetNames {
5756
char pci_path[ALTIFNAMSIZ];
5857
char pci_onboard[ALTIFNAMSIZ];
5958
const char *pci_onboard_label;
60-
61-
char bcma_core[ALTIFNAMSIZ];
6259
} NetNames;
6360

6461
/* skip intermediate virtio devices */
@@ -1028,14 +1025,17 @@ static int get_bcma_specifier(sd_device *dev, char **ret) {
10281025
return 0;
10291026
}
10301027

1031-
static int names_bcma(sd_device *dev, NetNames *names) {
1028+
static int names_bcma(sd_device *dev, const char *prefix, NetNames *names, bool test) {
10321029
_cleanup_free_ char *suffix = NULL;
10331030
sd_device *bcmadev;
10341031
int r;
10351032

10361033
assert(dev);
1034+
assert(prefix);
10371035
assert(names);
10381036

1037+
/* Broadcom bus */
1038+
10391039
r = sd_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL, &bcmadev);
10401040
if (r < 0)
10411041
return log_device_debug_errno(dev, r, "Could not get bcma parent device: %m");
@@ -1044,9 +1044,14 @@ static int names_bcma(sd_device *dev, NetNames *names) {
10441044
if (r < 0)
10451045
return r;
10461046

1047-
size_t l = strscpy(names->bcma_core, sizeof(names->bcma_core), strempty(suffix));
1048-
if (l != 0)
1049-
names->type = NET_BCMA;
1047+
char str[ALTIFNAMSIZ];
1048+
if (names->pci_path[0] &&
1049+
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names->pci_path, suffix))
1050+
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
1051+
1052+
if (names->pci_slot[0] &&
1053+
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names->pci_slot, suffix))
1054+
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
10501055

10511056
return 0;
10521057
}
@@ -1412,20 +1417,7 @@ static int builtin_net_id(UdevEvent *event, int argc, char *argv[], bool test) {
14121417
}
14131418

14141419
(void) names_usb(dev, prefix, &names, test);
1415-
1416-
/* Broadcom bus */
1417-
if (names_bcma(dev, &names) >= 0 && names.type == NET_BCMA) {
1418-
char str[ALTIFNAMSIZ];
1419-
1420-
if (names.pci_path[0] &&
1421-
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.bcma_core))
1422-
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
1423-
1424-
if (names.pci_slot[0] &&
1425-
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_slot, names.bcma_core))
1426-
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
1427-
return 0;
1428-
}
1420+
(void) names_bcma(dev, prefix, &names, test);
14291421

14301422
return 0;
14311423
}

0 commit comments

Comments
 (0)