]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_table.c
powerpc: Remove optimized finite
[thirdparty/glibc.git] / nis / nis_table.c
index 70b4701419a11bdd462ffef688f345376682178d..c443f531333045a1c0c84ca8c87955b70c7ea685 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 1997-1999, 2003, 2004, 2005, 2006, 2007
-   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@suse.de>, 1997.
 
    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 <string.h>
 #include <rpcsvc/nis.h>
+#include <libc-diag.h>
+#include <shlib-compat.h>
 
 #include "nis_xdr.h"
 #include "nis_intern.h"
@@ -94,15 +94,15 @@ __create_ib_request (const_nis_name name, unsigned int flags)
       if (cptr != NULL)
        *cptr++ = '\0';
 
-      if (__builtin_expect (val == NULL, 0))
+      if (__glibc_unlikely (val == NULL))
        {
          nis_free_request (ibreq);
          return NULL;
        }
       *val++ = '\0';
       if (search_len + 1 >= size)
-        {
-          size += 1;
+       {
+         size += 1;
          nis_attr *newp = realloc (search_val, size * sizeof (nis_attr));
          if (newp == NULL)
            goto free_null;
@@ -128,7 +128,7 @@ __create_ib_request (const_nis_name name, unsigned int flags)
 
   return ibreq;
 }
-libnsl_hidden_def (__create_ib_request)
+libnsl_hidden_nolink_def (__create_ib_request, GLIBC_PRIVATE)
 
 static const struct timeval RPCTIMEOUT = {10, 0};
 
@@ -177,6 +177,12 @@ __follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq,
 
       *tableptr = *tablepath;
     }
+
+  /* Since tableptr is only set here, and it's set when tablepath is NULL,
+     which it is initially defined as, we know it will always be set here.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
+
   if (*tableptr == NULL)
     return NIS_NOTFOUND;
 
@@ -184,6 +190,8 @@ __follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq,
   if (newname[0] == '\0')
     return NIS_NOTFOUND;
 
+  DIAG_POP_NEEDS_COMMENT;
+
   newname = strdup (newname);
   if (newname == NULL)
     return NIS_NOMEMORY;
@@ -193,7 +201,7 @@ __follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq,
 
   return NIS_SUCCESS;
 }
-libnsl_hidden_def (__follow_path)
+libnsl_hidden_nolink_def (__follow_path, GLIBC_PRIVATE)
 
 
 nis_result *
@@ -279,12 +287,12 @@ nis_list (const_nis_name name, unsigned int flags,
                                 &dir, &bptr, flags & ~MASTER_ONLY);
       if (status != NIS_SUCCESS)
        {
-          NIS_RES_STATUS (res) = status;
-          goto fail3;
+         NIS_RES_STATUS (res) = status;
+         goto fail3;
        }
 
       while (__nisbind_connect (&bptr) != NIS_SUCCESS)
-       if (__builtin_expect (__nisbind_next (&bptr) != NIS_SUCCESS, 0))
+       if (__glibc_unlikely (__nisbind_next (&bptr) != NIS_SUCCESS))
          {
            NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
            goto fail;
@@ -304,7 +312,7 @@ nis_list (const_nis_name name, unsigned int flags,
                               (xdrproc_t) _xdr_nis_result,
                               (caddr_t) res, RPCTIMEOUT);
 
-      if (__builtin_expect (clnt_status != RPC_SUCCESS, 0))
+      if (__glibc_unlikely (clnt_status != RPC_SUCCESS))
        NIS_RES_STATUS (res) = NIS_RPCERROR;
       else
        switch (NIS_RES_STATUS (res))
@@ -318,7 +326,7 @@ nis_list (const_nis_name name, unsigned int flags,
                free (ibreq->ibr_name);
                ibreq->ibr_name = NULL;
                /* If we hit the link limit, bail.  */
-               if (__builtin_expect (count_links > NIS_MAXLINKS, 0))
+               if (__glibc_unlikely (count_links > NIS_MAXLINKS))
                  {
                    NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
                    ++done;
@@ -368,11 +376,12 @@ nis_list (const_nis_name name, unsigned int flags,
            else if ((flags & FOLLOW_PATH)
                     && NIS_RES_STATUS (res) == NIS_PARTIAL)
              {
-               clnt_status = __follow_path (&tablepath, &tableptr, ibreq,
-                                            &bptr);
-               if (clnt_status != NIS_SUCCESS)
+               enum nis_error err = __follow_path (&tablepath, &tableptr,
+                                                   ibreq, &bptr);
+               if (err != NIS_SUCCESS)
                  {
-                   NIS_RES_STATUS (res) = clnt_status;
+                   if (err == NIS_NOMEMORY)
+                     NIS_RES_STATUS (res) = err;
                    ++done;
                  }
                else
@@ -427,15 +436,15 @@ nis_list (const_nis_name name, unsigned int flags,
                    NIS_RES_STATUS (allres) = NIS_RES_STATUS (res);
                    xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res);
                  }
-               clnt_status = __follow_path (&tablepath, &tableptr, ibreq,
-                                            &bptr);
-               if (clnt_status != NIS_SUCCESS)
+               enum nis_error err = __follow_path (&tablepath, &tableptr,
+                                                   ibreq, &bptr);
+               if (err != NIS_SUCCESS)
                  {
                    /* Prepare for the nis_freeresult call.  */
                    memset (res, '\0', sizeof (*res));
 
-                   if (clnt_status == NIS_NOMEMORY)
-                     NIS_RES_STATUS (allres) = clnt_status;
+                   if (err == NIS_NOMEMORY)
+                     NIS_RES_STATUS (allres) = err;
                    ++done;
                  }
              }
@@ -452,10 +461,14 @@ nis_list (const_nis_name name, unsigned int flags,
                  ++done;
                else
                  {
-                   NIS_RES_STATUS (res)
+                   enum nis_error err
                      = __follow_path (&tablepath, &tableptr, ibreq, &bptr);
-                   if (NIS_RES_STATUS (res) != NIS_SUCCESS)
-                     ++done;
+                   if (err != NIS_SUCCESS)
+                     {
+                       if (err == NIS_NOMEMORY)
+                         NIS_RES_STATUS (res) = err;
+                       ++done;
+                     }
                  }
              }
            break;
@@ -488,7 +501,7 @@ nis_list (const_nis_name name, unsigned int flags,
                /* Try the next domainname if we don't follow a link.  */
                free (ibreq->ibr_name);
                ibreq->ibr_name = NULL;
-               if (__builtin_expect (count_links, 0))
+               if (__glibc_unlikely (count_links))
                  {
                    NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
                    ++done;
@@ -540,7 +553,7 @@ nis_list (const_nis_name name, unsigned int flags,
 
   return res;
 }
-libnsl_hidden_def (nis_list)
+libnsl_hidden_nolink_def (nis_list, GLIBC_2_1)
 
 nis_result *
 nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags)
@@ -594,13 +607,14 @@ nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags)
                                   (caddr_t) ibreq,
                                   (xdrproc_t) _xdr_nis_result,
                                   (caddr_t) res, 0, NULL);
-  if (__builtin_expect (status != NIS_SUCCESS, 0))
+  if (__glibc_unlikely (status != NIS_SUCCESS))
     NIS_RES_STATUS (res) = status;
 
   nis_free_request (ibreq);
 
   return res;
 }
+libnsl_hidden_nolink_def (nis_add_entry, GLIBC_2_1)
 
 nis_result *
 nis_modify_entry (const_nis_name name, const nis_object *obj2,
@@ -651,13 +665,14 @@ nis_modify_entry (const_nis_name name, const nis_object *obj2,
                         (xdrproc_t) _xdr_ib_request,
                         (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                         (caddr_t) res, 0, NULL);
-  if (__builtin_expect (status != NIS_SUCCESS, 0))
+  if (__glibc_unlikely (status != NIS_SUCCESS))
     NIS_RES_STATUS (res) = status;
 
   nis_free_request (ibreq);
 
   return res;
 }
+libnsl_hidden_nolink_def (nis_modify_entry, GLIBC_2_1)
 
 nis_result *
 nis_remove_entry (const_nis_name name, const nis_object *obj,
@@ -706,6 +721,7 @@ nis_remove_entry (const_nis_name name, const nis_object *obj,
 
   return res;
 }
+libnsl_hidden_nolink_def (nis_remove_entry, GLIBC_2_1)
 
 nis_result *
 nis_first_entry (const_nis_name name)
@@ -736,13 +752,14 @@ nis_first_entry (const_nis_name name)
                         (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                         (caddr_t) res, 0, NULL);
 
-  if (__builtin_expect (status != NIS_SUCCESS, 0))
+  if (__glibc_unlikely (status != NIS_SUCCESS))
     NIS_RES_STATUS (res) = status;
 
   nis_free_request (ibreq);
 
   return res;
 }
+libnsl_hidden_nolink_def (nis_first_entry, GLIBC_2_1)
 
 nis_result *
 nis_next_entry (const_nis_name name, const netobj *cookie)
@@ -779,7 +796,7 @@ nis_next_entry (const_nis_name name, const netobj *cookie)
                         (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
                         (caddr_t) res, 0, NULL);
 
-  if (__builtin_expect (status != NIS_SUCCESS, 0))
+  if (__glibc_unlikely (status != NIS_SUCCESS))
     NIS_RES_STATUS (res) = status;
 
   if (cookie != NULL)
@@ -793,3 +810,4 @@ nis_next_entry (const_nis_name name, const netobj *cookie)
 
   return res;
 }
+libnsl_hidden_nolink_def (nis_next_entry, GLIBC_2_1)