Then the function interface_ensure_tslabel() could be removed safely.
Signed-off-by: Hangbin Liu <[email protected]>
---
clock.c | 5 ++---
interface.c | 8 +-------
interface.h | 6 ------
nsm.c | 5 ++---
pmc_common.c | 1 -
5 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/clock.c b/clock.c
index bbfd1a8..07bf582 100644
--- a/clock.c
+++ b/clock.c
@@ -1002,9 +1002,8 @@ struct clock *clock_create(enum clock_type type, struct
config *config,
required_modes = clock_required_modes(c);
STAILQ_FOREACH(iface, &config->interfaces, list) {
memset(ts_label, 0, sizeof(ts_label));
- rtnl_get_ts_device(interface_name(iface), ts_label);
- interface_set_label(iface, ts_label);
- interface_ensure_tslabel(iface);
+ if (!rtnl_get_ts_device(interface_name(iface), ts_label))
+ interface_set_label(iface, ts_label);
interface_get_tsinfo(iface);
if (interface_tsinfo_valid(iface) &&
!interface_tsmodes_supported(iface, required_modes)) {
diff --git a/interface.c b/interface.c
index 65bdff0..a2bcac2 100644
--- a/interface.c
+++ b/interface.c
@@ -23,6 +23,7 @@ struct interface *interface_create(const char *name)
return NULL;
}
strncpy(iface->name, name, MAX_IFNAME_SIZE);
+ strncpy(iface->ts_label, name, MAX_IFNAME_SIZE);
return iface;
}
@@ -32,13 +33,6 @@ void interface_destroy(struct interface *iface)
free(iface);
}
-void interface_ensure_tslabel(struct interface *iface)
-{
- if (!iface->ts_label[0]) {
- memcpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
- }
-}
-
int interface_get_tsinfo(struct interface *iface)
{
return sk_get_ts_info(iface->ts_label, &iface->ts_info);
diff --git a/interface.h b/interface.h
index 8bf2727..acc183a 100644
--- a/interface.h
+++ b/interface.h
@@ -33,12 +33,6 @@ struct interface *interface_create(const char *name);
*/
void interface_destroy(struct interface *iface);
-/**
- * Ensures that an interface has a proper time stamping label.
- * @param iface The interface of interest.
- */
-void interface_ensure_tslabel(struct interface *iface);
-
/**
* Populate the time stamping information of a given interface.
* @param iface The interface of interest.
diff --git a/nsm.c b/nsm.c
index 5aa925b..8d4a362 100644
--- a/nsm.c
+++ b/nsm.c
@@ -274,9 +274,8 @@ static int nsm_open(struct nsm *nsm, struct config *cfg)
STAILQ_FOREACH(iface, &cfg->interfaces, list) {
ifname = interface_name(iface);
memset(ts_label, 0, sizeof(ts_label));
- rtnl_get_ts_device(ifname, ts_label);
- interface_set_label(iface, ts_label);
- interface_ensure_tslabel(iface);
+ if (!rtnl_get_ts_device(ifname, ts_label))
+ interface_set_label(iface, ts_label);
count++;
}
if (count != 1) {
diff --git a/pmc_common.c b/pmc_common.c
index 7a1dbb4..8603a4c 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -411,7 +411,6 @@ struct pmc *pmc_create(struct config *cfg, enum
transport_type transport_type,
pr_err("failed to create interface");
goto failed;
}
- interface_ensure_tslabel(pmc->iface);
if (transport_open(pmc->transport, pmc->iface,
&pmc->fdarray, TS_SOFTWARE)) {
--
2.31.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel