On Mon, 2026-07-27 at 15:15 +0200, Andrew Lunn wrote: > > > I hate all this line wrapping, btw. I'll defer to the net coding style > > if they insist, but my preference would just be just to have longer > > lines. Especially when it's a block of assignments like this, the > > wrapped form is *much* harder to read. > > This is a long function, probably longer than the coding style > suggests. So one option is to move the code within the for loop into a > helper. That might then allow unwrapped lines? > > That is kind of the point of the line length limit, to make you break > code up into lots of small functions which do one thing.
Huh? Are we looking at the same function? The version of
ptp_sys_offset_extended_attrs() I'm looking at, having fixed up the
gratuitous line wrapping, is about 60 lines — none of which are wider
than 100 characters. It's a simple setup and then loop over n_samples
of data captures. A helper function would only serve to obfuscate it.
static long ptp_sys_offset_extended_attrs(struct ptp_clock *ptp, void __user
*arg)
{
struct ptp_sys_offset_attrs *data __free(kfree) = NULL;
struct ptp_attrs_request request;
struct ptp_system_timestamp sts;
unsigned int n_samples;
int err;
if (copy_from_user(&request, arg, sizeof(request)))
return -EFAULT;
if (request.valid ||
request.num_samples > PTP_MAX_SAMPLES ||
request.num_samples == 0)
return -EINVAL;
err = ptp_validate_sys_offset_clockid(request.clock_id);
if (err)
return err;
n_samples = request.num_samples;
sts.clockid = request.clock_id;
data = kzalloc(struct_size(data, timestamps, n_samples), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->request.num_samples = n_samples;
for (unsigned int i = 0; i < n_samples; i++) {
struct ptp_clock_attrs att = {};
struct timespec64 ts;
if (ptp->info->gettimexattrs64)
err = ptp->info->gettimexattrs64(ptp->info, &ts,
&sts, &att);
else if (ptp->info->gettimex64)
err = ptp->info->gettimex64(ptp->info, &ts, &sts);
else
return -EOPNOTSUPP;
if (err)
return err;
/* Filter out disabled or unavailable clocks */
if (!sts.pre_sts.valid || !sts.post_sts.valid)
return -EINVAL;
data->timestamps[i].pre_systime.sys_time =
ktime_to_ns(sts.pre_sts.systime);
data->timestamps[i].pre_systime.sys_rawtime =
ktime_to_ns(sts.pre_sts.monoraw);
data->timestamps[i].pre_systime.sys_counter =
sts.pre_sts.cycles;
data->timestamps[i].pre_systime.sys_counter_id =
sts.pre_sts.cs_id;
data->timestamps[i].devtime.device_time.sec = ts.tv_sec;
data->timestamps[i].devtime.device_time.nsec = ts.tv_nsec;
data->timestamps[i].devtime.attrs = att;
data->timestamps[i].post_systime.sys_time =
ktime_to_ns(sts.post_sts.systime);
data->timestamps[i].post_systime.sys_rawtime =
ktime_to_ns(sts.post_sts.monoraw);
data->timestamps[i].post_systime.sys_counter =
sts.post_sts.cycles;
data->timestamps[i].post_systime.sys_counter_id =
sts.post_sts.cs_id;
}
return copy_to_user(arg, data,
struct_size(data, timestamps, n_samples)) ? -EFAULT
: 0;
}
smime.p7s
Description: S/MIME cryptographic signature
