]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nscd/nscd_getserv_r.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nscd / nscd_getserv_r.c
index f9ef0565d8575122d8dbb0c55cd21d03f5033d40..68a7b9c282f980fefa3f4b1e0790321a05ca0bc6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2007.
 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <not-cancel.h>
-#include <stdio-common/_itoa.h>
+#include <_itoa.h>
+#include <stdint.h>
 
 #include "nscd-client.h"
 #include "nscd_proto.h"
@@ -54,7 +54,7 @@ __nscd_getservbyport_r (int port, const char *proto,
   portstr[sizeof (portstr) - 1] = '\0';
   char *cp = _itoa_word (port, portstr + sizeof (portstr) - 1, 10, 0);
 
-  return nscd_getserv_r (cp, portstr + sizeof (portstr) - cp, proto,
+  return nscd_getserv_r (cp, portstr + sizeof (portstr) - 1 - cp, proto,
                         GETSERVBYPORT, result_buf, buf, buflen, result);
 }
 
@@ -141,7 +141,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
                                > recend, 0))
            goto out;
 
-#ifndef _STRING_ARCH_unaligned
+#if !_STRING_ARCH_unaligned
          /* The aliases_len array in the mapped database might very
             well be unaligned.  We will access it word-wise so on
             platforms which do not tolerate unaligned accesses we
@@ -189,7 +189,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
   /* No value found so far.  */
   *result = NULL;
 
-  if (__builtin_expect (serv_resp.found == -1, 0))
+  if (__glibc_unlikely (serv_resp.found == -1))
     {
       /* The daemon does not cache this database.  */
       __nss_not_use_nscd_services = 1;
@@ -300,7 +300,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
        }
 
       /* See whether this would exceed the buffer capacity.  */
-      if (__builtin_expect (cp > buf + buflen, 0))
+      if (__glibc_unlikely (cp > buf + buflen))
        {
          /* aliases_len array might contain garbage during nscd GC cycle,
             retry rather than fail in that case.  */
@@ -356,7 +356,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
@@ -374,7 +374,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
       if (retval != -1)
        {
          if (!alloca_aliases_len)
-           free (aliases_len);
+           free ((void *) aliases_len);
          goto retry;
        }
     }