Re: [PATCH v2 6/8] socket: Add SO_TIMESTAMP[NS]_NEW
From: Willem de Bruijn
Date: Wed Dec 12 2018 - 10:36:02 EST
> This did not address yet the previous comments on consistency and
> unnecessary code churn.
>
> The existing logic to differentiate SO_TIMESTAMP from SO_TIMESTAMPNS
> in both tcp_recv_timestamp and __sock_recv_timestamp is
>
> if (sock_flag(sk, SOCK_RCVTSTAMP)) {
> if (sock_flag(sk, SOCK_RCVTSTAMPNS))
> /* timespec case */
> else
> /* timeval case */
> }
>
> A new level of nesting needs to be added to differentiate .._OLD from .._NEW.
>
> Even if massively changing the original functions, please do so
> consistently, either
>
> if (sock_flag(sk, SOCK_RCVTSTAMP)) {
> if (sock_flag(sk, SOCK_TSTAMP_NEW) {
> /* new code */
> } else {
> if (sock_flag(sk, SOCK_RCVTSTAMPNS))
> /* timespec case */
> else
> /* timeval case */
> }
> }
This first example is wrong. I meant
if (sock_flag(sk, SOCK_RCVTSTAMP)) {
if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
if (sock_flag(sk, SOCK_TSTAMP_NEW)
/* new code */
else
/* timespec case */
} else {
if (sock_flag(sk, SOCK_TSTAMP_NEW)
/* new code */
else
/* timeval case */
}
}