Re: [Patch 1/8] Setup

Andrew Morton
2006-05-08T21:14:46Z

Balbir Singh <balbir@in.ibm.com> wrote:
>
> /*
> + * sub = end - start, in normalized form
> + */
> +static inline void timespec_sub(struct timespec *start, struct timespec *end,
> + struct timespec *sub)
> +{
> + set_normalized_timespec(sub, end->tv_sec - start->tv_sec,
> + end->tv_nsec - start->tv_nsec);
> +}

The interface might not be right here.

- I think "lhs" and "rhs" would be better names than "start" and "end".
After all, we don't _know_ that the caller is using the two times as a
start and an end. The caller might be taking the difference between two
differences, for example.

- The existing timespec and timeval funtions tend to do return-by-value.
So this would become

static inline struct timespec timespec_sub(struct timespec lhs,
struct timespec rhs)

(and given that it's inlined, the added overhead of passing the
arguments by value will be zero)

- If we don't want to do that then at least let's get the arguments in a
sane order:

static inline void timespec_sub(struct timespec *result,
struct timespec lhs, struct timespec rhs)