DragonFly bugs List (threaded) for 2006-12
DragonFly BSD
DragonFly bugs List (threaded) for 2006-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: confstr() should return 0, not -1, on errors


From: "Thomas E. Spanjaard" <tgen@xxxxxxxxxxxxx>
Date: Tue, 05 Dec 2006 19:22:20 +0000

Guy Harris wrote:
According to
http://www.opengroup.org/onlinepubs/009695399/functions/confstr.html
confstr() should return 0, not (size_t)-1, on errors. The current DragonFly BSD implementation returns -1 if sysctl() fails.

See attached patch.


Cheers,
--
        Thomas E. Spanjaard
        tgen@netphreax.net
Index: confstr.3
===================================================================
RCS file: /home/dcvs/src/lib/libc/gen/confstr.3,v
retrieving revision 1.3
diff -u -r1.3 confstr.3
--- confstr.3	26 May 2006 19:39:36 -0000	1.3
+++ confstr.3	5 Dec 2006 18:43:12 -0000
@@ -33,7 +33,7 @@
 .\" $FreeBSD: src/lib/libc/gen/confstr.3,v 1.5.2.5 2001/12/14 18:33:50 ru Exp $
 .\" $DragonFly: src/lib/libc/gen/confstr.3,v 1.3 2006/05/26 19:39:36 swildner Exp $
 .\"
-.Dd June 4, 1993
+.Dd December 5, 2006
 .Dt CONFSTR 3
 .Os
 .Sh NAME
@@ -90,7 +90,7 @@
 .Sh RETURN VALUES
 If the call to
 .Fn confstr
-is not successful, \-1 is returned and
+is not successful, 0 is returned and
 .Va errno
 is set appropriately.
 Otherwise, if the variable does not have a configuration defined value,
@@ -123,6 +123,8 @@
 .El
 .Sh SEE ALSO
 .Xr sysctl 3
+.Rs
+.St -p1003.2
 .Sh HISTORY
 The
 .Fn confstr
Index: confstr.c
===================================================================
RCS file: /home/dcvs/src/lib/libc/gen/confstr.c,v
retrieving revision 1.3
diff -u -r1.3 confstr.c
--- confstr.c	13 Nov 2005 00:07:42 -0000	1.3
+++ confstr.c	5 Dec 2006 18:32:40 -0000
@@ -55,15 +55,18 @@
 		mib[0] = CTL_USER;
 		mib[1] = USER_CS_PATH;
 		if (sysctl(mib, 2, NULL, &tlen, NULL, 0) == -1)
-			return (-1);
+			/*
+			 * POSIX 1003.2 requires errors to return 0.
+			 */
+			return (0);
 		if (len != 0 && buf != NULL) {
 			if ((p = malloc(tlen)) == NULL)
-				return (-1);
+				return (0);	/* POSIX 1003.2 */
 			if (sysctl(mib, 2, p, &tlen, NULL, 0) == -1) {
 				sverrno = errno;
 				free(p);
 				errno = sverrno;
-				return (-1);
+				return (0);	/* POSIX 1003.2 */
 			}
 			/*
 			 * POSIX 1003.2 requires partial return of

Attachment: signature.asc
Description: OpenPGP digital signature



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