The majority of the callers of transport_send() use hard coded magic
numbers.  This patch fixes them to use the corresponding enumerated
values instead.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 clock.c      |  2 +-
 nsm.c        |  2 +-
 pmc_common.c |  3 ++-
 port.c       | 19 ++++++++++---------
 port.h       |  6 +++---
 5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/clock.c b/clock.c
index bc67fb4..46fa5f2 100644
--- a/clock.c
+++ b/clock.c
@@ -469,7 +469,7 @@ static int clock_management_get_response(struct clock *c, 
struct port *p,
        }
        respond = clock_management_fill_response(c, p, req, rsp, id);
        if (respond)
-               port_prepare_and_send(p, rsp, 0);
+               port_prepare_and_send(p, rsp, TRANS_GENERAL);
        msg_put(rsp);
        return respond;
 }
diff --git a/nsm.c b/nsm.c
index fb87b3a..0fb73fb 100644
--- a/nsm.c
+++ b/nsm.c
@@ -436,7 +436,7 @@ static int nsm_request(struct nsm *nsm, char *target)
                pr_err("msg_pre_send failed");
                goto out;
        }
-       cnt = transport_sendto(nsm->trp, &nsm->fda, 1, msg);
+       cnt = transport_sendto(nsm->trp, &nsm->fda, TRANS_EVENT, msg);
        if (cnt <= 0) {
                pr_err("transport_sendto failed");
                err = -1;
diff --git a/pmc_common.c b/pmc_common.c
index 9d21210..d1eafe7 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -160,7 +160,8 @@ static int pmc_send(struct pmc *pmc, struct ptp_message 
*msg)
                pr_err("msg_pre_send failed");
                return -1;
        }
-       return transport_send(pmc->transport, &pmc->fdarray, 0, msg);
+       return transport_send(pmc->transport, &pmc->fdarray,
+                             TRANS_GENERAL, msg);
 }
 
 static int pmc_tlv_datalen(struct pmc *pmc, int id)
diff --git a/port.c b/port.c
index 9d04326..7bbca8c 100644
--- a/port.c
+++ b/port.c
@@ -938,7 +938,7 @@ static int port_management_get_response(struct port *target,
        }
        respond = port_management_fill_response(target, rsp, id);
        if (respond)
-               port_prepare_and_send(ingress, rsp, 0);
+               port_prepare_and_send(ingress, rsp, TRANS_GENERAL);
        msg_put(rsp);
        return respond;
 }
@@ -1293,7 +1293,7 @@ int port_delay_request(struct port *p)
                msg->header.flagField[0] |= UNICAST;
        }
 
-       if (port_prepare_and_send(p, msg, 1)) {
+       if (port_prepare_and_send(p, msg, TRANS_EVENT)) {
                pr_err("port %hu: send delay request failed", portnum(p));
                goto out;
        }
@@ -1349,7 +1349,7 @@ static int port_tx_announce(struct port *p)
                pr_err("port %hu: append path trace failed", portnum(p));
        }
 
-       err = port_prepare_and_send(p, msg, 0);
+       err = port_prepare_and_send(p, msg, TRANS_GENERAL);
        if (err)
                pr_err("port %hu: send announce failed", portnum(p));
        msg_put(msg);
@@ -1449,7 +1449,7 @@ static int port_tx_sync(struct port *p, struct address 
*dst)
                goto out;
        }
 
-       err = port_prepare_and_send(p, fup, 0);
+       err = port_prepare_and_send(p, fup, TRANS_GENERAL);
        if (err)
                pr_err("port %hu: send follow up failed", portnum(p));
 out:
@@ -1746,7 +1746,7 @@ static int process_delay_req(struct port *p, struct 
ptp_message *m)
                err = -1;
                goto out;
        }
-       err = port_prepare_and_send(p, msg, 0);
+       err = port_prepare_and_send(p, msg, TRANS_GENERAL);
        if (err) {
                pr_err("port %hu: send delay response failed", portnum(p));
                goto out;
@@ -2513,18 +2513,19 @@ static enum fsm_event bc_event(struct port *p, int 
fd_index)
 int port_forward(struct port *p, struct ptp_message *msg)
 {
        int cnt;
-       cnt = transport_send(p->trp, &p->fda, 0, msg);
+       cnt = transport_send(p->trp, &p->fda, TRANS_GENERAL, msg);
        return cnt <= 0 ? -1 : 0;
 }
 
 int port_forward_to(struct port *p, struct ptp_message *msg)
 {
        int cnt;
-       cnt = transport_sendto(p->trp, &p->fda, 0, msg);
+       cnt = transport_sendto(p->trp, &p->fda, TRANS_GENERAL, msg);
        return cnt <= 0 ? -1 : 0;
 }
 
-int port_prepare_and_send(struct port *p, struct ptp_message *msg, int event)
+int port_prepare_and_send(struct port *p, struct ptp_message *msg,
+                         enum transport_event event)
 {
        int cnt;
 
@@ -2638,7 +2639,7 @@ int port_management_error(struct PortIdentity pid, struct 
port *ingress,
        mes->error = error_id;
        mes->id = mgt->id;
 
-       err = port_prepare_and_send(ingress, msg, 0);
+       err = port_prepare_and_send(ingress, msg, TRANS_GENERAL);
        msg_put(msg);
        return err;
 }
diff --git a/port.h b/port.h
index a76b2bd..d828875 100644
--- a/port.h
+++ b/port.h
@@ -105,10 +105,10 @@ int port_forward_to(struct port *p, struct ptp_message 
*msg);
  * port_forward if you need to send single message to several ports.
  * @param p        A pointer previously obtained via port_open().
  * @param msg      The message to send.
- * @param event    0 if the message is a general message, 1 if it is an
- *                 event message.
+ * @param event    One of the @ref transport_event enumeration values.
  */
-int port_prepare_and_send(struct port *p, struct ptp_message *msg, int event);
+int port_prepare_and_send(struct port *p, struct ptp_message *msg,
+                         enum transport_event event);
 
 /**
  * Obtain a port's identity.
-- 
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

Reply via email to