Re: [Linuxptp-devel] [PATCH RFC 13/30] Convert call sites to the proper method for initializing the time stamping label.

2020-02-18 Thread Jacob Keller



On 2/11/2020 6:04 AM, Richard Cochran wrote:
> Signed-off-by: Richard Cochran 
> ---
>  clock.c  | 12 +---
>  nsm.c|  4 +---
>  pmc_common.c |  4 +---
>  3 files changed, 3 insertions(+), 17 deletions(-)
> 

Reviewed-by: Jacob Keller 

> diff --git a/clock.c b/clock.c
> index f987965..3895d09 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -842,16 +842,6 @@ int clock_required_modes(struct clock *c)
>   return required_modes;
>  }
>  
> -/*
> - * If we do not have a slave or the rtnl query failed, then use our
> - * own interface name as the time stamping interface name.
> - */
> -static void ensure_ts_label(struct interface *iface)
> -{
> - if (iface->ts_label[0] == '\0')
> - strncpy(iface->ts_label, interface_name(iface), 
> MAX_IFNAME_SIZE);
> -}
> -

Removing both open-coded and the implementation in another .c file. Nice!

Thanks,
Jake

>  struct clock *clock_create(enum clock_type type, struct config *config,
>  const char *phc_device)
>  {
> @@ -961,7 +951,7 @@ struct clock *clock_create(enum clock_type type, struct 
> config *config,
>   required_modes = clock_required_modes(c);
>   STAILQ_FOREACH(iface, &config->interfaces, list) {
>   rtnl_get_ts_device(interface_name(iface), iface->ts_label);
> - ensure_ts_label(iface);
> + interface_ensure_tslabel(iface);
>   interface_get_tsinfo(iface);
>   if (iface->ts_info.valid &&
>   ((iface->ts_info.so_timestamping & required_modes) != 
> required_modes)) {
> diff --git a/nsm.c b/nsm.c
> index 269c3c8..e82fc37 100644
> --- a/nsm.c
> +++ b/nsm.c
> @@ -269,9 +269,7 @@ static int nsm_open(struct nsm *nsm, struct config *cfg)
>   STAILQ_FOREACH(iface, &cfg->interfaces, list) {
>   ifname = interface_name(iface);
>   rtnl_get_ts_device(ifname, iface->ts_label);
> - if (iface->ts_label[0] == '\0') {
> - strncpy(iface->ts_label, ifname, MAX_IFNAME_SIZE);
> - }
> + interface_ensure_tslabel(iface);
>   count++;
>   }
>   if (count != 1) {
> diff --git a/pmc_common.c b/pmc_common.c
> index d5c8b61..6bdaa94 100644
> --- a/pmc_common.c
> +++ b/pmc_common.c
> @@ -351,9 +351,7 @@ struct pmc *pmc_create(struct config *cfg, enum 
> transport_type transport_type,
>   }
>  
>   strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
> - if (iface.ts_label[0] == '\0') {
> - strncpy(iface.ts_label, interface_name(&iface), 
> MAX_IFNAME_SIZE);
> - }
> + interface_ensure_tslabel(&iface);
>  
>   if (transport_open(pmc->transport, &iface,
>  &pmc->fdarray, TS_SOFTWARE)) {
> 


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH RFC 13/30] Convert call sites to the proper method for initializing the time stamping label.

2020-02-11 Thread Richard Cochran
Signed-off-by: Richard Cochran 
---
 clock.c  | 12 +---
 nsm.c|  4 +---
 pmc_common.c |  4 +---
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/clock.c b/clock.c
index f987965..3895d09 100644
--- a/clock.c
+++ b/clock.c
@@ -842,16 +842,6 @@ int clock_required_modes(struct clock *c)
return required_modes;
 }
 
-/*
- * If we do not have a slave or the rtnl query failed, then use our
- * own interface name as the time stamping interface name.
- */
-static void ensure_ts_label(struct interface *iface)
-{
-   if (iface->ts_label[0] == '\0')
-   strncpy(iface->ts_label, interface_name(iface), 
MAX_IFNAME_SIZE);
-}
-
 struct clock *clock_create(enum clock_type type, struct config *config,
   const char *phc_device)
 {
@@ -961,7 +951,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
required_modes = clock_required_modes(c);
STAILQ_FOREACH(iface, &config->interfaces, list) {
rtnl_get_ts_device(interface_name(iface), iface->ts_label);
-   ensure_ts_label(iface);
+   interface_ensure_tslabel(iface);
interface_get_tsinfo(iface);
if (iface->ts_info.valid &&
((iface->ts_info.so_timestamping & required_modes) != 
required_modes)) {
diff --git a/nsm.c b/nsm.c
index 269c3c8..e82fc37 100644
--- a/nsm.c
+++ b/nsm.c
@@ -269,9 +269,7 @@ static int nsm_open(struct nsm *nsm, struct config *cfg)
STAILQ_FOREACH(iface, &cfg->interfaces, list) {
ifname = interface_name(iface);
rtnl_get_ts_device(ifname, iface->ts_label);
-   if (iface->ts_label[0] == '\0') {
-   strncpy(iface->ts_label, ifname, MAX_IFNAME_SIZE);
-   }
+   interface_ensure_tslabel(iface);
count++;
}
if (count != 1) {
diff --git a/pmc_common.c b/pmc_common.c
index d5c8b61..6bdaa94 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -351,9 +351,7 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
}
 
strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
-   if (iface.ts_label[0] == '\0') {
-   strncpy(iface.ts_label, interface_name(&iface), 
MAX_IFNAME_SIZE);
-   }
+   interface_ensure_tslabel(&iface);
 
if (transport_open(pmc->transport, &iface,
   &pmc->fdarray, TS_SOFTWARE)) {
-- 
2.20.1



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel