On 2/11/2020 6:04 AM, Richard Cochran wrote:
> In many cases, the time stamping label will be the same as the name of
> the interface.  In order to prevent users from open coding the logic that
> initializes the label from the interface name, this patch add an
> appropriate method.
> 
> Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
> ---
>  interface.c | 7 +++++++
>  interface.h | 6 ++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/interface.c b/interface.c
> index 460ceb8..662552d 100644
> --- a/interface.c
> +++ b/interface.c
> @@ -6,6 +6,13 @@
>   */
>  #include "interface.h"
>  
> +void interface_ensure_tslabel(struct interface *iface)
> +{
> +     if (!iface->ts_label[0]) {

The original code did "if (label[0] == '\0')" but this is equivalent. Ok.

> +             strncpy(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 05cfb10..371185d 100644
> --- a/interface.h
> +++ b/interface.h
> @@ -24,6 +24,12 @@ struct interface {
>       struct sk_ts_info ts_info;
>  };
>  
> +/**
> + * 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.
> 


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

Reply via email to