]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_findserv.c
Fix http: URL in 'configure'
[thirdparty/glibc.git] / nis / nis_findserv.c
index f3e6cd83188c6f32c8f2d8879c22fdfd2a7156a2..2a9c45bf67fa75f87c5a99e717f983f68fbc5ce1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
 #include <time.h>
@@ -63,7 +63,7 @@ __pmap_getnisport (struct sockaddr_in *address, u_long program,
 struct findserv_req
 {
   struct sockaddr_in sin;
-  u_int32_t xid;
+  uint32_t xid;
   u_int server_nr;
   u_int server_ep;
 };
@@ -77,7 +77,7 @@ __nis_findfastest_with_timeout (dir_binding *bind,
   struct findserv_req *pings;
   struct sockaddr_in sin, saved_sin;
   int found = -1;
-  u_int32_t xid_seed;
+  uint32_t xid_seed;
   int sock, dontblock = 1;
   CLIENT *clnt;
   u_long i, j, pings_count, pings_max, fastest = -1;
@@ -87,9 +87,9 @@ __nis_findfastest_with_timeout (dir_binding *bind,
                                           for multihomed hosts */
   pings_count = 0;
   pings = malloc (sizeof (struct findserv_req) * pings_max);
-  xid_seed = (u_int32_t) (time (NULL) ^ getpid ());
+  xid_seed = (uint32_t) (time (NULL) ^ getpid ());
 
-  if (__builtin_expect (pings == NULL, 0))
+  if (__glibc_unlikely (pings == NULL))
     return -1;
 
   memset (&sin, '\0', sizeof (sin));
@@ -97,9 +97,9 @@ __nis_findfastest_with_timeout (dir_binding *bind,
   for (i = 0; i < bind->server_len; i++)
     for (j = 0; j < bind->server_val[i].ep.ep_len; ++j)
       if (strcmp (bind->server_val[i].ep.ep_val[j].family, "inet") == 0)
-       if ((bind->server_val[i].ep.ep_val[j].proto == NULL) ||
-           (bind->server_val[i].ep.ep_val[j].proto[0] == '-') ||
-           (bind->server_val[i].ep.ep_val[j].proto[0] == '\0'))
+       if ((bind->server_val[i].ep.ep_val[j].proto == NULL)
+           || (bind->server_val[i].ep.ep_val[j].proto[0] == '-')
+           || (bind->server_val[i].ep.ep_val[j].proto[0] == '\0'))
          {
            sin.sin_addr.s_addr =
              inetstr2int (bind->server_val[i].ep.ep_val[j].uaddr);
@@ -118,7 +118,7 @@ __nis_findfastest_with_timeout (dir_binding *bind,
                pings_max += 10;
                new_pings = realloc (pings, sizeof (struct findserv_req) *
                                     pings_max);
-               if (__builtin_expect (new_pings == NULL, 0))
+               if (__glibc_unlikely (new_pings == NULL))
                  {
                    free (pings);
                    return -1;
@@ -127,7 +127,7 @@ __nis_findfastest_with_timeout (dir_binding *bind,
              }
            memcpy ((char *) &pings[pings_count].sin, (char *) &sin,
                    sizeof (sin));
-           memcpy ((char *)&saved_sin, (char *)&sin, sizeof(sin));
+           memcpy ((char *)&saved_sin, (char *)&sin, sizeof (sin));
            pings[pings_count].xid = xid_seed + pings_count;
            pings[pings_count].server_nr = i;
            pings[pings_count].server_ep = j;
@@ -142,7 +142,7 @@ __nis_findfastest_with_timeout (dir_binding *bind,
     }
 
   /* Create RPC handle */
-  sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+  sock = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
   clnt = clntudp_create (&saved_sin, NIS_PROG, NIS_VERSION, *timeout, &sock);
   if (clnt == NULL)
     {
@@ -158,7 +158,7 @@ __nis_findfastest_with_timeout (dir_binding *bind,
   for (i = 0; i < pings_count; ++i)
     {
       /* clntudp_call() will increment, subtract one */
-      *((u_int32_t *) (cu->cu_outbuf)) = pings[i].xid - 1;
+      *((uint32_t *) (cu->cu_outbuf)) = pings[i].xid - 1;
       memcpy ((char *) &cu->cu_raddr, (char *) &pings[i].sin,
              sizeof (struct sockaddr_in));
       /* Transmit to NULLPROC, return immediately. */
@@ -174,8 +174,8 @@ __nis_findfastest_with_timeout (dir_binding *bind,
                        (xdrproc_t) xdr_void, (caddr_t) 0,
                        *timeout);
     if (RPC_SUCCESS == rc) {
-      u_int32_t val;
-      memcpy (&val, cu->cu_inbuf, sizeof (u_int32_t));
+      uint32_t val;
+      memcpy (&val, cu->cu_inbuf, sizeof (uint32_t));
       fastest = val - xid_seed;
       if (fastest < pings_count) {
        bind->server_used = pings[fastest].server_nr;