Re: [Linuxptp-devel] [PATCH RFC 16/30] interface: Introduce a method to set the time stamping label.

2020-02-18 Thread Jacob Keller
On 2/11/2020 6:04 AM, Richard Cochran wrote:
> The ts_label field of the interface is set in different ways by different
> callers.  In order to prevent users from open coding the logic that sets
> the label, this patch adds an appropriate method.
> 
> Signed-off-by: Richard Cochran 

Reviewed-by: Jacob Keller 

> ---
>  interface.c | 5 +
>  interface.h | 7 +++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/interface.c b/interface.c
> index 3811679..d7eeb41 100644
> --- a/interface.c
> +++ b/interface.c
> @@ -28,6 +28,11 @@ const char *interface_name(struct interface *iface)
>   return iface->name;
>  }
>  
> +void interface_set_label(struct interface *iface, const char *label)
> +{
> + strncpy(iface->ts_label, label, MAX_IFNAME_SIZE);
> +}

Same here, it might be a good idea to ensure that last byte
(MAX_IFNAME_SIZE + 1) is set to '\0'.

> +
>  void interface_set_name(struct interface *iface, const char *name)
>  {
>   strncpy(iface->name, name, MAX_IFNAME_SIZE);
> diff --git a/interface.h b/interface.h
> index 5f449ae..f416b24 100644
> --- a/interface.h
> +++ b/interface.h
> @@ -53,6 +53,13 @@ const char *interface_label(struct interface *iface);
>   */
>  const char *interface_name(struct interface *iface);
>  
> +/**
> + * Set the time stamping label of a given interface.
> + * @param iface  The interface of interest.
> + * @param name   The desired label for the interface.
> + */
> +void interface_set_label(struct interface *iface, const char *label);
> +
>  /**
>   * Set the name 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


[Linuxptp-devel] [PATCH RFC 16/30] interface: Introduce a method to set the time stamping label.

2020-02-11 Thread Richard Cochran
The ts_label field of the interface is set in different ways by different
callers.  In order to prevent users from open coding the logic that sets
the label, this patch adds an appropriate method.

Signed-off-by: Richard Cochran 
---
 interface.c | 5 +
 interface.h | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/interface.c b/interface.c
index 3811679..d7eeb41 100644
--- a/interface.c
+++ b/interface.c
@@ -28,6 +28,11 @@ const char *interface_name(struct interface *iface)
return iface->name;
 }
 
+void interface_set_label(struct interface *iface, const char *label)
+{
+   strncpy(iface->ts_label, label, MAX_IFNAME_SIZE);
+}
+
 void interface_set_name(struct interface *iface, const char *name)
 {
strncpy(iface->name, name, MAX_IFNAME_SIZE);
diff --git a/interface.h b/interface.h
index 5f449ae..f416b24 100644
--- a/interface.h
+++ b/interface.h
@@ -53,6 +53,13 @@ const char *interface_label(struct interface *iface);
  */
 const char *interface_name(struct interface *iface);
 
+/**
+ * Set the time stamping label of a given interface.
+ * @param iface  The interface of interest.
+ * @param name   The desired label for the interface.
+ */
+void interface_set_label(struct interface *iface, const char *label);
+
 /**
  * Set the name of a given interface.
  * @param iface  The interface of interest.
-- 
2.20.1



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