Reviewed-by: Jacob Keller <jacob.e.kel...@intel.com> On 5/16/2020 8:03 AM, Richard Cochran wrote: > The transport layer's functional interface foresees having error codes > percolate back up to the caller. However, up until now, the sk module > simply returned -1 for any error. This patch lets the code return the > specific error instead. > > Signed-off-by: Richard Cochran <richardcoch...@gmail.com> > --- > sk.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/sk.c b/sk.c > index e211175..c9ef4d2 100644 > --- a/sk.c > +++ b/sk.c > @@ -354,7 +354,7 @@ int sk_receive(int fd, void *buf, int buflen, > "timed out while polling for tx > timestamp"); > pr_err("increasing tx_timestamp_timeout may correct " > "this issue, but it is likely caused by a driver > bug"); > - return res; > + return -errno; > } else if (!(pfd.revents & sk_revents)) { > pr_err("poll for tx timestamp woke up on non ERR > event"); > return -1; > @@ -362,24 +362,24 @@ int sk_receive(int fd, void *buf, int buflen, > } > > cnt = recvmsg(fd, &msg, flags); > - if (cnt < 0) > + if (cnt < 0) { > pr_err("recvmsg%sfailed: %m", > flags == MSG_ERRQUEUE ? " tx timestamp " : " "); > - > + }
Nice. I dislike style where {} is not used when it's 'technically' a one-line statement even though it appears over multiple lines. This avoids having to catch that when reading the code. This wasn't mentioned in the commit message though. > for (cm = CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) { > level = cm->cmsg_level; > type = cm->cmsg_type; > if (SOL_SOCKET == level && SO_TIMESTAMPING == type) { > if (cm->cmsg_len < sizeof(*ts) * 3) { > pr_warning("short SO_TIMESTAMPING message"); > - return -1; > + return -EMSGSIZE; > } > ts = (struct timespec *) CMSG_DATA(cm); > } > if (SOL_SOCKET == level && SO_TIMESTAMPNS == type) { > if (cm->cmsg_len < sizeof(*sw)) { > pr_warning("short SO_TIMESTAMPNS message"); > - return -1; > + return -EMSGSIZE; > } > sw = (struct timespec *) CMSG_DATA(cm); > hwts->sw = timespec_to_tmv(*sw); > @@ -391,7 +391,7 @@ int sk_receive(int fd, void *buf, int buflen, > > if (!ts) { > memset(&hwts->ts, 0, sizeof(hwts->ts)); > - return cnt; > + return cnt < 1 ? -errno : cnt; > } > > switch (hwts->type) { > @@ -407,7 +407,7 @@ int sk_receive(int fd, void *buf, int buflen, > hwts->ts = timespec_to_tmv(ts[1]); > break; > } > - return cnt; > + return cnt < 1 ? -errno : cnt; > } > > int sk_set_priority(int fd, int family, uint8_t dscp) > _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel