[CRIU] Re: [PATCH 1/2] sk-inet: More detailed error parsing on unconnected socket

Pavel Emelyanov xemul at parallels.com
Tue Oct 30 11:05:53 EDT 2012


On 10/30/2012 06:47 PM, Cyrill Gorcunov wrote:
> errno is no guaranteed to be clear if call exit with
> success. Thus make sure we've ret negative here and
> test for errno then.
> 
> http://bugzilla.openvz.org/show_bug.cgi?id=2412
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  sk-inet.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/sk-inet.c b/sk-inet.c
> index 6382bd5..500aa63 100644
> --- a/sk-inet.c
> +++ b/sk-inet.c
> @@ -167,8 +167,13 @@ static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p)
>  	/* It should has no peer name */
>  	aux = sizeof(address);
>  	ret = getsockopt(lfd, SOL_SOCKET, SO_PEERNAME, address, &aux);
> -	if (ret != -1 || errno != ENOTCONN) {
> -		pr_err("Errno %d returned from unconnected socket\n", errno);
> +	if (ret < 0) {
> +		if (errno != ENOTCONN) {

This should break zdtm. Patch #2 will fix, but for git-bisect-ness it's better to swap patches.

> +			pr_perror("Unexpected error returned from unconnected socket");
> +			goto err;
> +		}
> +	} else if (ret == 0) {
> +		pr_err("Name resolved on unconnected socket\n");
>  		goto err;
>  	}
>  
> 




More information about the CRIU mailing list