Re: Asys P7131 Hybrid: DVB out of range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 06, 2007, Andreas Oberritter wrote:> > Quoting from the manpage of strtol():> > The strtol() function returns the result of the conversion, unless the> value would underflow or overflow.  If an  underflow  occurs,  strtol()> returns  LONG_MIN.   If  an overflow occurs, strtol() returns LONG_MAX.> In both cases, errno is set to ERANGE.  Precisely the  same  holds  for> strtoll()  (with  LLONG_MIN  and  LLONG_MAX  instead  of  LONG_MIN  and> LONG_MAX).
You should've read on:
 NOTES	Since  strtol()  can  legitimately  return  0, LONG_MAX, or	LONG_MIN (LLONG_MAX or LLONG_MIN for str‐ toll()) on both	success and failure, the calling program should set errno to 0	before the  call,  and then determine if an error occurred by	checking whether errno has a non-zero value after the call.
I think your patch is buggy, because errno is not guaranteedto be reset to zero after successful calls (see the errno manpage).

Regards,Johannes

> diff -r 1923f74d97ae util/szap/azap.c> --- a/util/szap/azap.c	Wed Jun 27 19:46:43 2007 +0200> +++ b/util/szap/azap.c	Thu Sep 06 02:47:52 2007 +0200> @@ -104,6 +104,8 @@ int parse_int(int fd, int *val)>  	};>  >  	*val = strtol(number, NULL, 10);> +	if (errno == ERANGE)> +		return -4;>  >  	return 0;>  }> diff -r 1923f74d97ae util/szap/tzap.c> --- a/util/szap/tzap.c	Wed Jun 27 19:46:43 2007 +0200> +++ b/util/szap/tzap.c	Thu Sep 06 02:47:52 2007 +0200> @@ -180,6 +180,8 @@ int parse_int(int fd, int *val)>  	};>  >  	*val = strtol(number, NULL, 10);> +	if (errno == ERANGE)> +		return -4;>  >  	return 0;>  }
> _______________________________________________> linux-dvb mailing list> linux-dvb@xxxxxxxxxxx> http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
_______________________________________________linux-dvb mailing listlinux-dvb@xxxxxxxxxxxxxxx://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux