[PATCH v5] tests: Add test for decoding of PTP_* ioctl commands
Dmitry V. Levin
ldv at altlinux.org
Sun Mar 11 11:17:26 UTC 2018
On Sun, Mar 11, 2018 at 12:21:22PM +0530, Harsha Sharma wrote:
> * tests/ioctl_ptp.c: New file.
> * tests/.gitignore: Add ioctl_ptp.
> * tests/gen_tests.in (ioctl_ptp): New entry.
> * tests/pure_executables.list: Likewise.
> ---
> Changes in v5:
> * change sysoff->n_samples = PTP_MAX_SAMPLES
[...]
> + /* PTP_SYS_OFFSET */
> + sysoff->n_samples = PTP_MAX_SAMPLES;
> + int sysoff_ret = ioctl(fd, PTP_SYS_OFFSET, sysoff);
> + if (sysoff_ret < 0) {
> + printf("ioctl(%d, PTP_SYS_OFFSET, {n_samples=%u}) = %s\n",
> + fd, sysoff->n_samples, sprintrc(sysoff_ret));
> + } else {
> + unsigned int n_samples, i;
> +
> + printf("ioctl(%d, PTP_SYS_OFFSET, ts=[", fd);
> + n_samples = sysoff->n_samples > PTP_MAX_SAMPLES ?
> + PTP_MAX_SAMPLES : sysoff->n_samples;
> + for (i = 0; i < 2 * n_samples + 1; ++i) {
> + if (i > 0)
> + printf(", ");
> + printf("{sec=%" PRId64 ", nsec=%" PRIu32 "}",
> + (int64_t)sysoff->ts[i].sec, sysoff->ts[i].nsec);
> + }
> + if (sysoff->n_samples > PTP_MAX_SAMPLES)
> + printf(", ...");
> + printf("]) = %s\n", sprintrc(sysoff_ret));
> + }
As sysoff->n_samples is set to PTP_MAX_SAMPLES now,
why do you need all these (sysoff->n_samples > PTP_MAX_SAMPLES) checks?
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180311/69016937/attachment.bin>
More information about the Strace-devel
mailing list