about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-09-04 12:31:47 +0000
committerUlrich Drepper <drepper@redhat.com>2003-09-04 12:31:47 +0000
commita452e4e6294ffb6d7362215cb0b10896e8a7631f (patch)
tree8d839077bad9b595e265ef7db5b81bc29a010449
parente3c54d80553ebee8253b52d16f3284a5a93707cd (diff)
downloadglibc-a452e4e6294ffb6d7362215cb0b10896e8a7631f.tar.gz
glibc-a452e4e6294ffb6d7362215cb0b10896e8a7631f.tar.xz
glibc-a452e4e6294ffb6d7362215cb0b10896e8a7631f.zip
Update.
2003-09-04  Ulrich Drepper  <drepper@redhat.com>

	* nss/getXXbyYY.c (FUNCTION_NAME): Add a few casts.  Remove
	unnecessary errno handling.

	* nss/getXXbyYY_r.c (INTERNAL): Use better variable name.
	Initialize it in all cases.  Change it to be a bit more like the
	code we had before.
-rw-r--r--ChangeLog9
-rw-r--r--nss/getXXbyYY.c13
-rw-r--r--nss/getXXbyYY_r.c17
3 files changed, 22 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 87221156c1..1a3c5261ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-09-04  Ulrich Drepper  <drepper@redhat.com>
+
+	* nss/getXXbyYY.c (FUNCTION_NAME): Add a few casts.  Remove
+	unnecessary errno handling.
+
+	* nss/getXXbyYY_r.c (INTERNAL): Use better variable name.
+	Initialize it in all cases.  Change it to be a bit more like the
+	code we had before.
+
 2003-09-04  Jakub Jelinek  <jakub@redhat.com>
 
 	* libio/fileops.c (_IO_file_read, _IO_new_file_write): Add
diff --git a/nss/getXXbyYY.c b/nss/getXXbyYY.c
index ece2a0d47c..07e1d8a088 100644
--- a/nss/getXXbyYY.c
+++ b/nss/getXXbyYY.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001,2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -106,7 +106,7 @@ FUNCTION_NAME (ADD_PARAMS)
   if (buffer == NULL)
     {
       buffer_size = BUFLEN;
-      buffer = malloc (buffer_size);
+      buffer = (char *) malloc (buffer_size);
     }
 
 #ifdef HANDLE_DIGITS_DOTS
@@ -132,14 +132,13 @@ FUNCTION_NAME (ADD_PARAMS)
     {
       char *new_buf;
       buffer_size += BUFLEN;
-      new_buf = realloc (buffer, buffer_size);
+      new_buf = (char *) realloc (buffer, buffer_size);
       if (new_buf == NULL)
 	{
 	  /* We are out of memory.  Free the current buffer so that the
 	     process gets a chance for a normal termination.  */
-	  save = errno;
 	  free (buffer);
-	  __set_errno (save);
+	  __set_errno (ENOMEM);
 	}
       buffer = new_buf;
     }
@@ -150,10 +149,8 @@ FUNCTION_NAME (ADD_PARAMS)
 #ifdef HANDLE_DIGITS_DOTS
 done:
 #endif
-  /* Release lock.  Preserve error value.  */
-  save = errno;
+  /* Release lock.  */
   __libc_lock_unlock (lock);
-  __set_errno (save);
 
 #ifdef NEED_H_ERRNO
   if (h_errno_tmp != 0)
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index a0e0e003b7..99639593b8 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -248,23 +248,22 @@ done:
   POSTPROCESS;
 #endif
 
-  int result;
+  int res;
   if (status == NSS_STATUS_SUCCESS)
-    result = 0;
+    res = 0;
   /* Don't pass back ERANGE if this is not for a too-small buffer.  */
   else if (errno == ERANGE && status != NSS_STATUS_TRYAGAIN)
-    {
+    res = EINVAL;
 #ifdef NEED_H_ERRNO
-      /* These functions only set errno if h_errno is NETDB_INTERNAL.  */
-      if (*h_errnop != NETDB_INTERNAL)
+  /* These functions only set errno if h_errno is NETDB_INTERNAL.  */
+  else if (status == NSS_STATUS_TRYAGAIN && *h_errnop != NETDB_INTERNAL)
+    res = EAGAIN;
 #endif
-	result = ENOENT;
-    }
   else
     return errno;
 
-  __set_errno (result);
-  return result;
+  __set_errno (res);
+  return res;
 }