Subject: Re: [PATCH 2/2] ping6: Fix -F switch.

From: Jan Synacek <[email-masked]>
Date: Mon, 10 Dec 2012 10:58:39 +0100

On 12/07/2012 09:25 AM, Jan Synacek wrote:
> Even when the flowlabel is set correctly, ping6 exits with a warning. For some
> reason, the errno is set when it should not be.
> 
> Signed-off-by: Jan Synacek <[email-masked]>
> ---
>  ping6.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ping6.c b/ping6.c
> index 358a035..85d3782 100644
> --- a/ping6.c
> +++ b/ping6.c
> @@ -725,7 +725,8 @@ int main(int argc, char *argv[])
>  		switch(ch) {
>  		case 'F':
>  			flowlabel = hextoui(optarg);
> -			if (errno || (flowlabel & ~IPV6_FLOWINFO_FLOWLABEL)) {
> +			if ((flowlabel < 0 && errno) ||
> +			    (flowlabel & ~IPV6_FLOWINFO_FLOWLABEL)) {
>  				fprintf(stderr, "ping: Invalid flowinfo %s\n", optarg);
>  				exit(2);
>  			}
> 

This was well meant, but it doesn't work, because flowlabel is declared as
__u32, therefore it can never be negative. I'm going to post a fixed version soon.

-- 
Jan Synacek
Software Engineer, BaseOS team Brno, Red Hat