Re: [Linuxptp-devel] [PATCH RFC 20/30] interface: Introduce a method to test the time stamping information validity.
On 3/4/2020 9:13 AM, Richard Cochran wrote: > On Tue, Feb 18, 2020 at 01:19:09PM -0800, Jacob Keller wrote: >>> +bool interface_tsinfo_valid(struct interface *iface) >>> +{ >>> + return iface->ts_info.valid ? true : false; >>> +} >> >> Do you actually need the ternary here? shouldn't ts_info.valid get >> converted to true or false because we are returning a boolean? > > Right. > >> I don't think this is harmful and you may consider it improving >> readability though. > > Yeah, that is the reason. I like to have it spelled out in this case. > > Thanks, > Richard > Sure. Thanks, Jake ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH RFC 20/30] interface: Introduce a method to test the time stamping information validity.
On Tue, Feb 18, 2020 at 01:19:09PM -0800, Jacob Keller wrote: > > +bool interface_tsinfo_valid(struct interface *iface) > > +{ > > + return iface->ts_info.valid ? true : false; > > +} > > Do you actually need the ternary here? shouldn't ts_info.valid get > converted to true or false because we are returning a boolean? Right. > I don't think this is harmful and you may consider it improving > readability though. Yeah, that is the reason. I like to have it spelled out in this case. Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH RFC 20/30] interface: Introduce a method to test the time stamping information validity.
On 2/11/2020 6:04 AM, Richard Cochran wrote: > Signed-off-by: Richard Cochran Reviewed-by: Jacob Keller > --- > interface.c | 5 + > interface.h | 8 > 2 files changed, 13 insertions(+) > > diff --git a/interface.c b/interface.c > index 02f63a0..7a3eddc 100644 > --- a/interface.c > +++ b/interface.c > @@ -42,3 +42,8 @@ void interface_set_name(struct interface *iface, const char > *name) > { > strncpy(iface->name, name, MAX_IFNAME_SIZE); > } > + > +bool interface_tsinfo_valid(struct interface *iface) > +{ > + return iface->ts_info.valid ? true : false; > +} Do you actually need the ternary here? shouldn't ts_info.valid get converted to true or false because we are returning a boolean? I don't think this is harmful and you may consider it improving readability though. Thanks, Jake > diff --git a/interface.h b/interface.h > index 4f408d5..3526a48 100644 > --- a/interface.h > +++ b/interface.h > @@ -7,6 +7,7 @@ > #ifndef HAVE_INTERFACE_H > #define HAVE_INTERFACE_H > > +#include > #include > #include "sk.h" > > @@ -74,4 +75,11 @@ void interface_set_label(struct interface *iface, const > char *label); > */ > void interface_set_name(struct interface *iface, const char *name); > > +/** > + * Tests whether an interface's time stamping information is valid or not. > + * @param iface The interface of interest. > + * @return True if the time stamping information is valid, false > otherwise. > + */ > +bool interface_tsinfo_valid(struct interface *iface); > + > #endif > ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH RFC 20/30] interface: Introduce a method to test the time stamping information validity.
Signed-off-by: Richard Cochran --- interface.c | 5 + interface.h | 8 2 files changed, 13 insertions(+) diff --git a/interface.c b/interface.c index 02f63a0..7a3eddc 100644 --- a/interface.c +++ b/interface.c @@ -42,3 +42,8 @@ void interface_set_name(struct interface *iface, const char *name) { strncpy(iface->name, name, MAX_IFNAME_SIZE); } + +bool interface_tsinfo_valid(struct interface *iface) +{ + return iface->ts_info.valid ? true : false; +} diff --git a/interface.h b/interface.h index 4f408d5..3526a48 100644 --- a/interface.h +++ b/interface.h @@ -7,6 +7,7 @@ #ifndef HAVE_INTERFACE_H #define HAVE_INTERFACE_H +#include #include #include "sk.h" @@ -74,4 +75,11 @@ void interface_set_label(struct interface *iface, const char *label); */ void interface_set_name(struct interface *iface, const char *name); +/** + * Tests whether an interface's time stamping information is valid or not. + * @param iface The interface of interest. + * @return True if the time stamping information is valid, false otherwise. + */ +bool interface_tsinfo_valid(struct interface *iface); + #endif -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel