> -----Original Message-----
> From: Richard Cochran [mailto:richardcoch...@gmail.com]
> Sent: Saturday, April 07, 2018 8:06 PM
> To: linuxptp-devel@lists.sourceforge.net
> Subject: [Linuxptp-devel] [PATCH RFC 1/8] transport: Use the proper
> enumerated event code.
> 
> Originally the 'event' parameter to transport_send() was a single
> Boolean flag.  Over time, we grew an enumerated list of event
> flavors, but the function signatures were never updated.  This patch
> changes the methods to use the proper type.
> 

Nice cleanup.. It also helps keep the documentation accurate, since we already 
had an enumerated list of events, but the function header comment only mentions 
0 and 1.

Thanks,
Jake

> Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
> ---
>  raw.c               |  6 +++---
>  transport.c         | 12 ++++++------
>  transport.h         | 18 +++++++++---------
>  transport_private.h |  6 +++---
>  udp.c               |  6 +++---
>  udp6.c              |  6 +++---
>  uds.c               |  6 +++---
>  7 files changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/raw.c b/raw.c
> index d9a3468..937f473 100644
> --- a/raw.c
> +++ b/raw.c
> @@ -290,9 +290,9 @@ static int raw_recv(struct transport *t, int fd, void 
> *buf, int
> buflen,
>       return cnt;
>  }
> 
> -static int raw_send(struct transport *t, struct fdarray *fda, int event,
> -                 int peer, void *buf, int len, struct address *addr,
> -                 struct hw_timestamp *hwts)
> +static int raw_send(struct transport *t, struct fdarray *fda,
> +                 enum transport_event event, int peer, void *buf, int len,
> +                 struct address *addr, struct hw_timestamp *hwts)
>  {
>       struct raw *raw = container_of(t, struct raw, t);
>       ssize_t cnt;
> diff --git a/transport.c b/transport.c
> index 3541394..ff5e307 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -42,24 +42,24 @@ int transport_recv(struct transport *t, int fd, struct
> ptp_message *msg)
>       return t->recv(t, fd, msg, sizeof(msg->data), &msg->address, &msg-
> >hwts);
>  }
> 
> -int transport_send(struct transport *t, struct fdarray *fda, int event,
> -                struct ptp_message *msg)
> +int transport_send(struct transport *t, struct fdarray *fda,
> +                enum transport_event event, struct ptp_message *msg)
>  {
>       int len = ntohs(msg->header.messageLength);
> 
>       return t->send(t, fda, event, 0, msg, len, NULL, &msg->hwts);
>  }
> 
> -int transport_peer(struct transport *t, struct fdarray *fda, int event,
> -                struct ptp_message *msg)
> +int transport_peer(struct transport *t, struct fdarray *fda,
> +                enum transport_event event, struct ptp_message *msg)
>  {
>       int len = ntohs(msg->header.messageLength);
> 
>       return t->send(t, fda, event, 1, msg, len, NULL, &msg->hwts);
>  }
> 
> -int transport_sendto(struct transport *t, struct fdarray *fda, int event,
> -                  struct ptp_message *msg)
> +int transport_sendto(struct transport *t, struct fdarray *fda,
> +                  enum transport_event event, struct ptp_message *msg)
>  {
>       int len = ntohs(msg->header.messageLength);
> 
> diff --git a/transport.h b/transport.h
> index 05df53b..5c8a051 100644
> --- a/transport.h
> +++ b/transport.h
> @@ -67,12 +67,12 @@ int transport_recv(struct transport *t, int fd, struct
> ptp_message *msg);
>   * ptp_message itself is ignored.
>   * @param t  The transport.
>   * @param fda        The array of descriptors filled in by transport_open.
> - * @param event      1 for event message, 0 for general message.
> + * @param event      One of the @ref transport_event enumeration values.
>   * @param msg        The message to send.
>   * @return   Number of bytes send, or negative value in case of an error.
>   */
> -int transport_send(struct transport *t, struct fdarray *fda, int event,
> -                struct ptp_message *msg);
> +int transport_send(struct transport *t, struct fdarray *fda,
> +                enum transport_event event, struct ptp_message *msg);
> 
>  /**
>   * Sends the PTP message using the given transport. The message is sent to
> @@ -80,25 +80,25 @@ int transport_send(struct transport *t, struct fdarray 
> *fda,
> int event,
>   * address), any address field in the ptp_message itself is ignored.
>   * @param t  The transport.
>   * @param fda        The array of descriptors filled in by transport_open.
> - * @param event      1 for event message, 0 for general message.
> + * @param event      One of the @ref transport_event enumeration values.
>   * @param msg        The message to send.
>   * @return   Number of bytes send, or negative value in case of an error.
>   */
> -int transport_peer(struct transport *t, struct fdarray *fda, int event,
> -                struct ptp_message *msg);
> +int transport_peer(struct transport *t, struct fdarray *fda,
> +                enum transport_event event, struct ptp_message *msg);
> 
>  /**
>   * Sends the PTP message using the given transport. The address has to be
>   * provided in the address field of the message.
>   * @param t  The transport.
>   * @param fda        The array of descriptors filled in by transport_open.
> - * @param event      1 for event message, 0 for general message.
> + * @param event      One of the @ref transport_event enumeration values.
>   * @param msg        The message to send. The address of the destination has
> to
>   *           be set in the address field.
>   * @return   Number of bytes send, or negative value in case of an error.
>   */
> -int transport_sendto(struct transport *t, struct fdarray *fda, int event,
> -                  struct ptp_message *msg);
> +int transport_sendto(struct transport *t, struct fdarray *fda,
> +                  enum transport_event event, struct ptp_message *msg);
> 
>  /**
>   * Returns the transport's type.
> diff --git a/transport_private.h b/transport_private.h
> index 7530896..ec28e47 100644
> --- a/transport_private.h
> +++ b/transport_private.h
> @@ -38,9 +38,9 @@ struct transport {
>       int (*recv)(struct transport *t, int fd, void *buf, int buflen,
>                   struct address *addr, struct hw_timestamp *hwts);
> 
> -     int (*send)(struct transport *t, struct fdarray *fda, int event,
> -                 int peer, void *buf, int buflen, struct address *addr,
> -                 struct hw_timestamp *hwts);
> +     int (*send)(struct transport *t, struct fdarray *fda,
> +                 enum transport_event event, int peer, void *buf, int buflen,
> +                 struct address *addr, struct hw_timestamp *hwts);
> 
>       void (*release)(struct transport *t);
> 
> diff --git a/udp.c b/udp.c
> index 05c2ba0..3ac489e 100644
> --- a/udp.c
> +++ b/udp.c
> @@ -215,9 +215,9 @@ static int udp_recv(struct transport *t, int fd, void 
> *buf, int
> buflen,
>       return sk_receive(fd, buf, buflen, addr, hwts, 0);
>  }
> 
> -static int udp_send(struct transport *t, struct fdarray *fda, int event,
> -                 int peer, void *buf, int len, struct address *addr,
> -                 struct hw_timestamp *hwts)
> +static int udp_send(struct transport *t, struct fdarray *fda,
> +                 enum transport_event event, int peer, void *buf, int len,
> +                 struct address *addr, struct hw_timestamp *hwts)
>  {
>       ssize_t cnt;
>       int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL];
> diff --git a/udp6.c b/udp6.c
> index 7551e3f..12213d7 100644
> --- a/udp6.c
> +++ b/udp6.c
> @@ -225,9 +225,9 @@ static int udp6_recv(struct transport *t, int fd, void 
> *buf,
> int buflen,
>       return sk_receive(fd, buf, buflen, addr, hwts, 0);
>  }
> 
> -static int udp6_send(struct transport *t, struct fdarray *fda, int event,
> -                 int peer, void *buf, int len, struct address *addr,
> -                 struct hw_timestamp *hwts)
> +static int udp6_send(struct transport *t, struct fdarray *fda,
> +                  enum transport_event event, int peer, void *buf, int len,
> +                  struct address *addr, struct hw_timestamp *hwts)
>  {
>       struct udp6 *udp6 = container_of(t, struct udp6, t);
>       ssize_t cnt;
> diff --git a/uds.c b/uds.c
> index 7e11f63..44d135f 100644
> --- a/uds.c
> +++ b/uds.c
> @@ -108,9 +108,9 @@ static int uds_recv(struct transport *t, int fd, void 
> *buf, int
> buflen,
>       return cnt;
>  }
> 
> -static int uds_send(struct transport *t, struct fdarray *fda, int event,
> -                 int peer, void *buf, int buflen, struct address *addr,
> -                 struct hw_timestamp *hwts)
> +static int uds_send(struct transport *t, struct fdarray *fda,
> +                 enum transport_event event, int peer, void *buf, int buflen,
> +                 struct address *addr, struct hw_timestamp *hwts)
>  {
>       int cnt, fd = fda->fd[FD_GENERAL];
>       struct uds *uds = container_of(t, struct uds, t);
> --
> 2.11.0
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linuxptp-devel mailing list
> Linuxptp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to