On Wed, Jun 14, 2017 at 03:01:11PM +0800, JingPiao Chen wrote: > 2017-06-14 12:35 GMT+08:00 Dmitry V. Levin <[email protected]>: > > On Wed, Jun 14, 2017 at 11:53:02AM +0800, JingPiao Chen wrote: > > > On Wed, Jun 14, 2017 at 05:06:06AM +0300, Dmitry V. Levin wrote: > > > > On Wed, Jun 14, 2017 at 03:19:46AM +0300, Dmitry V. Levin wrote: [...] > > > > > I see. Would it be better to print the address instead of the > string > > > > > in case of umove failure, e.g. > > > > > > > > > > if (len < sizeof(msg)) > > > > > return false; > > > > > > > > > > if (umove_or_printaddr(tcp, addr, &msg)) > > > > > return true; > > > > > > > > OK, I've changed this parser a bit and pushed it again to ldv/netlink > > > > branch, please have a look. > > > Ok, thank you. > > > > ... and again, amending the last commit to simplify subsequent > > netlink_sock_diag test changes. > > I have some questions, why do not use: > if (len < sizeof(msg)) > return false; > > if (umove_or_printaddr(tcp, addr, &msg)) > return true; > > Can we remove offset?
These two code snippets are almost equivalent:
const size_t offset = sizeof(msg.udiag_family);
if (!umoven_or_printaddr(tcp, addr + offset,
sizeof(msg) - offset,
(void *) &msg + offset)) {
and
if (umove(tcp, addr, &msg) < 0)
printaddr(addr + sizeof(msg.udiag_family));
else {
except the second one fetches msg.udiag_family for the second time.
Why would you prefer it over the first one?
[..]
> Can we print address when len < sizeof(msg)?
> Why print ... when len < sizeof(msg)?
How would you distinguish the case when the specified length was correct
but the fetch failed from the case when the specified length was wrong?
--
ldv
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
