On Tue, Jun 21, 2016 at 12:44:45PM +0000, Fabien Siron wrote:
> Quoting Dmitry V. Levin (2016-06-20 23:40:38)
> > On Mon, Jun 20, 2016 at 04:06:45PM +0000, Fabien Siron wrote:
> > > This commit handles the case where there are several messages in the 
> > > buffer.
> > > This is very useful to some protocols like SOCK_DIAG.
> > > 
> > > * netlink.c (nlmsg_fetch, nlmsg_next): New functions.
> > > (decode_netlink_msg): New function.
> > > (decode_netlink): Call decode_netlink_msg().
> > > * tests/netlink_parsing.c (send_query): Adapt test.
> > > ---
> > >  netlink.c               | 45 
> > > +++++++++++++++++++++++++++++++++++++++++++--
> > >  tests/netlink_parsing.c |  8 ++++----
> > >  2 files changed, 47 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/netlink.c b/netlink.c
> > > index c43f6e7..fecc413 100644
> > > --- a/netlink.c
> > > +++ b/netlink.c
> > > @@ -31,8 +31,34 @@
> [...]
> > > +void
> > > +decode_netlink(struct tcb *tcp, unsigned long addr, unsigned long 
> > > total_size) {
> > > +     struct nlmsghdr nlmsghdr;
> > > +     unsigned long size = total_size;
> > > +
> > > +     for (; nlmsg_fetch(tcp, &nlmsghdr, addr, size);
> > > +          addr = nlmsg_next(&nlmsghdr, addr, &size)) {
> > > +             if (size != total_size)
> > > +                     tprints(", ");
> > > +             tprints("{");
> > > +             decode_netlink_msg(tcp, addr, size);
> > > +             tprints("}");
> > 
> > Square brackets are more appropriate for this sequence of structures,
> > one before the first element and one after the last.  No need to enclose
> > each element in additional brackets.  I'd say if there is only one
> > element, no need to enclose it in additional brackets, too.
> > 
> > Should there be a limit on the number of elements printed?
> 
> Well, maybe a limit could be useful in non verbose, but in verbose everything
> should be printed, isn't it?

For example, print_array in abbrev(tcp) mode limits number of printed
elements to max_strlen.


-- 
ldv

Attachment: pgp3LCEIJ58Nu.pgp
Description: PGP signature

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to