[PATCH] msghdr: print SCM_TIMESTAMP* control messages

Dmitry V. Levin ldv at altlinux.org
Thu Jun 15 09:17:43 UTC 2017


On Thu, Jun 15, 2017 at 10:54:59AM +0200, Miroslav Lichvar wrote:
> On Thu, Jun 15, 2017 at 11:43:37AM +0300, Dmitry V. Levin wrote:
> > On Thu, Jun 15, 2017 at 10:06:47AM +0200, Miroslav Lichvar wrote:
> > > Ok. I guess I need to add new printing functions and check the length
> > > there, but I'm not sure how to name them. Would the following work?
> > > 
> > > MPERS_PRINTER_DECL(void, print_timeval_data,
> > > 		   const void *arg, const size_t size)
> > > MPERS_PRINTER_DECL(void, print_timespec_data,
> > > 		   const void *arg, const size_t size)
> > > MPERS_PRINTER_DECL(void, print_timespec_array, const void *arg,
> > > 		   const unsigned int nmemb, const size_t size)
> > 
> > If they were regular pure printers, nowadays they would be called
> > - print_struct_timeval,
> > - print_struct_timespec,
> > - print_struct_timespec_array
> > In fact, print_struct_timeval already exists and does exactly that.
> > 
> > If you are going to add modifications of these functions that also accept
> > data length along with data pointer, ideally this should be reflected
> > in their name, e.g. print_struct_timeval_data_size.
> 
> Ok.
> 
> > What do you think these functions should print in case the data size
> > is smaller than necessary?
> 
> Nothing. Is there a better option?

If you print nothing, you'd end up with this on x86_64:
msg_control=[{cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_TIMESTAMP, cmsg_data=}]
It doesn't look nice, does it?

> > A side note: new SCM_* constants are arch-specific.
> 
> I think the values are the same on most archs.

Yes, with parisc and sparc as exceptions.

> If they don't have a
> default value, the compilation will fail on systems that don't have
> them yet. Would it be preferred to check for them in configure and
> disable the printers if missing?

I've just added some ifdefery to xlat/scmvals.in, but tests/msg_control.c
is going to use these constants, too, and if you ifdefed them there
you'd effectively disable new tests because most of these constants
hasn't been added to libc headers yet.


-- 
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/20170615/2bb0c36a/attachment.bin>


More information about the Strace-devel mailing list