On Thu, Apr 07, 2022 at 01:32:50AM -0700, Richard Cochran wrote:
> On Thu, Apr 07, 2022 at 11:43:41AM +0800, Hangbin Liu wrote:
> > Is there anything still unclear?
> 
> Yes, not a thing is clear to me!

Sorry for my bad English. I adjust the code, not sure if this time it would be
clear.

STAILQ_FOREACH(iface, &config->interfaces, list) {
        interface_get_tsinfo(iface);
        if (interface_tsinfo_valid(iface) &&
            interface_tsmodes_supported(iface, required_modes))
                continue;

        /* Get iface and check ts_info failed, let's see if there is
         * a useable ts_label and try get_tsinfo again */
        memset(ts_label, 0, sizeof(ts_label));
        if (!rtnl_get_ts_device(interface_name(iface), ts_label)) {
                interface_set_label(iface, ts_label);
                interface_get_tsinfo(iface);
                if (interface_tsinfo_valid(iface) &&
                                interface_tsmodes_supported(iface, 
required_modes))
                        continue;
        }

        pr_err("interface '%s' does not support requested timestamping mode",
                        interface_name(iface));
        return NULL;
}

> As it stands, the code is too twisted.  The repeated tests are a
> really bad code smell.


Yes, the previous code is bad. But in the worst case, there do need valid the
tsinfo twice. As we try get_tsinfo directly first, if failed, try update
ts_label and get_tsinfo again.

Thanks
Hangbin


_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to