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 22:23:43 +0000

Thomas E. Spanjaard wrote:
See attached patch.

And the next attached patch fixes the only consumer of confstr(3) in our tree (something the other BSDs don't appear to have done).


Cheers,
--
        Thomas E. Spanjaard
        tgen@netphreax.net
Index: getconf.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/getconf/getconf.c,v
retrieving revision 1.3
diff -u -r1.3 getconf.c
--- getconf.c	4 Nov 2003 20:25:45 -0000	1.3
+++ getconf.c	5 Dec 2006 22:21:43 -0000
@@ -141,8 +141,9 @@
 	char *buf;
 	size_t len;
 
+	errno = 0;
 	len = confstr(key, 0, 0);
-	if (len == (size_t)-1)
+	if (len == 0 && errno != 0)
 		err(EX_OSERR, "confstr: %s", name);
 	
 	if (len == 0) {

Attachment: signature.asc
Description: OpenPGP digital signature



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