In port_open(), don't assume that UDS ports always have to have a zero
number. Check the transport directly to make make the code cleaner.

Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
---
 port.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/port.c b/port.c
index 0a93c06..6136153 100644
--- a/port.c
+++ b/port.c
@@ -3108,23 +3108,25 @@ struct port *port_open(const char *phc_device,
        p->versionNumber = PTP_VERSION;
        p->slave_event_monitor = clock_slave_monitor(clock);
 
-       if (number && unicast_client_initialize(p)) {
+       if (transport != TRANS_UDS && unicast_client_initialize(p)) {
                goto err_transport;
        }
        if (unicast_client_enabled(p) &&
            config_set_section_int(cfg, p->name, "hybrid_e2e", 1)) {
                goto err_uc_client;
        }
-       if (number && unicast_service_initialize(p)) {
+       if (transport != TRANS_UDS && unicast_service_initialize(p)) {
                goto err_uc_client;
        }
        p->hybrid_e2e = config_get_int(cfg, p->name, "hybrid_e2e");
 
-       if (number && type == CLOCK_TYPE_P2P && p->delayMechanism != DM_P2P) {
+       if (transport != TRANS_UDS &&
+           type == CLOCK_TYPE_P2P && p->delayMechanism != DM_P2P) {
                pr_err("port %d: P2P TC needs P2P ports", number);
                goto err_uc_service;
        }
-       if (number && type == CLOCK_TYPE_E2E && p->delayMechanism != DM_E2E) {
+       if (transport != TRANS_UDS &&
+           type == CLOCK_TYPE_E2E && p->delayMechanism != DM_E2E) {
                pr_err("port %d: E2E TC needs E2E ports", number);
                goto err_uc_service;
        }
@@ -3158,7 +3160,7 @@ struct port *port_open(const char *phc_device,
 
        port_clear_fda(p, N_POLLFD);
        p->fault_fd = -1;
-       if (number) {
+       if (transport != TRANS_UDS) {
                p->fault_fd = timerfd_create(CLOCK_MONOTONIC, 0);
                if (p->fault_fd < 0) {
                        pr_err("timerfd_create failed: %m");
-- 
2.26.2



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

Reply via email to