[uClibc-cvs] svn commit: trunk/uClibc/libc/inet

andersen at uclibc.org andersen at uclibc.org
Thu Apr 28 18:57:26 UTC 2005


Author: andersen
Date: 2005-04-28 12:57:25 -0600 (Thu, 28 Apr 2005)
New Revision: 10199

Log:
Cleanup error case a bit


Modified:
   trunk/uClibc/libc/inet/resolv.c


Changeset:
Modified: trunk/uClibc/libc/inet/resolv.c
===================================================================
--- trunk/uClibc/libc/inet/resolv.c	2005-04-28 18:27:41 UTC (rev 10198)
+++ trunk/uClibc/libc/inet/resolv.c	2005-04-28 18:57:25 UTC (rev 10199)
@@ -674,7 +674,7 @@
 	char *dns, *lookup = malloc(MAXDNAME);
 	int variant = -1;
 	struct sockaddr_in sa;
-	int local_ns, local_id;
+	int local_ns = -1, local_id = -1;
 #ifdef __UCLIBC_HAS_IPV6__
 	int v6;
 	struct sockaddr_in6 sa6;
@@ -689,12 +689,10 @@
 
 	/* Mess with globals while under lock */
 	LOCK;
-	local_ns = ns;
+	local_ns = ns % nscount;
 	local_id = id;
 	UNLOCK;
 
-	local_ns %= nscount;
-
 	while (retries < MAX_RETRIES) {
 		if (fd != -1)
 			close(fd);
@@ -912,10 +910,12 @@
 	    free(packet);
 	h_errno = NETDB_INTERNAL;
 	/* Mess with globals while under lock */
-	LOCK;
-	ns = local_ns;
-	id = local_id;
-	UNLOCK;
+	if (local_ns != -1) {
+	    LOCK;
+	    ns = local_ns;
+	    id = local_id;
+	    UNLOCK;
+	}
 	return -1;
 }
 #endif




More information about the uClibc-cvs mailing list