[PATCH 1/3] Use the protocol name of a socket as a hint for peer address resolution
Dmitry V. Levin
ldv at altlinux.org
Mon Dec 8 17:57:22 UTC 2014
On Sun, Dec 07, 2014 at 06:56:13AM +0900, Masatake YAMATO wrote:
[...]
> --- a/socketutils.c
> +++ b/socketutils.c
> @@ -138,33 +138,56 @@ receive_responses(const int fd, const unsigned long inode)
> }
> }
>
> +static bool
> +inet_print(int fd, int family, int protocol, const unsigned long inode)
> +{
> + if (!send_query(fd, family, protocol))
> + return false;
> + if (receive_responses(fd, inode))
> + return true;
> + return false;
> +}
You can simply write it this way:
return send_query(fd, family, protocol) &&
receive_responses(fd, inode);
[...]
> + for (fi = 0; fi < flen; ++fi) {
> + for (pi = 0; pi < plen; ++pi) {
> + if (!send_query(fd, families[fi], protocols[pi]))
> + continue;
> + if (receive_responses(fd, inode)) {
> + r = true;
> + goto out;
> + }
> }
> }
This could be written using your new function inet_print.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20141208/f23c03dc/attachment.bin>
More information about the Strace-devel
mailing list