Re: Asys P7131 Hybrid: DVB out of range

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

 



Hello Johannes,

Johannes Stezenbach wrote:
> 	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 guaranteed
> to be reset to zero after successful calls (see the errno manpage).

Right. Here's an updated patch.

@Manu: I am using hg anonymously and I don't even know whether I have
write access or not. It would be nice if you can commit it.

Regards,
Andreas
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 19:04:37 2007 +0200
@@ -103,7 +103,10 @@ int parse_int(int fd, int *val)
 			return -3;	/*  to fit in 32 bit */
 	};
 
+	errno = 0;
 	*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 19:04:37 2007 +0200
@@ -179,7 +179,10 @@ int parse_int(int fd, int *val)
 			return -3;	/*  to fit in 32 bit */
 	};
 
+	errno = 0;
 	*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

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

  Powered by Linux