Re: [patch 07/13] ptp: Split out PTP_SYS_OFFSET ioctl code

From: Vadim Fedorenko
Date: Sat Jun 21 2025 - 16:58:27 EST


On 21/06/2025 21:42, Thomas Gleixner wrote:
On Sat, Jun 21 2025 at 21:14, Vadim Fedorenko wrote:
On 20/06/2025 14:24, Thomas Gleixner wrote:
+ pct = &sysoff->ts[0];
+ for (unsigned int i = 0; i < sysoff->n_samples; i++) {
+ struct ptp_clock_info *ops = ptp->info;

Looks like *ops initialization can be moved outside of the loop.

Well it can, but does it matter? No, because this is only a coding
artifact. The compiler can evaluate ptp->info inside of the loop at his
own peril even on both usage sites.

Though what's more important is that from a context point of view, ops
belongs into the loop, because that's where it is used and not outside,
no?

Well, in the original code it was always outside of any loops. And the
scope a bit bigger, all these functions work with ptp_clock object, so
the context is really subjective. It just looks a bit weird to de-
reference something, which is known not to change, every iteration. Of
course the compiler is smart enough to optimize it, but still..


Thanks,

tglx