-/* 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"
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;
return ibreq;
}
-libnsl_hidden_def (__create_ib_request)
+libnsl_hidden_nolink_def (__create_ib_request, GLIBC_PRIVATE)
static const struct timeval RPCTIMEOUT = {10, 0};
*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;
if (newname[0] == '\0')
return NIS_NOTFOUND;
+ DIAG_POP_NEEDS_COMMENT;
+
newname = strdup (newname);
if (newname == NULL)
return NIS_NOMEMORY;
return NIS_SUCCESS;
}
-libnsl_hidden_def (__follow_path)
+libnsl_hidden_nolink_def (__follow_path, GLIBC_PRIVATE)
nis_result *
&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;
(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))
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;
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)
{
- if (clnt_status == NIS_NOMEMORY)
- NIS_RES_STATUS (res) = clnt_status;
+ if (err == NIS_NOMEMORY)
+ NIS_RES_STATUS (res) = err;
++done;
}
else
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;
}
}
++done;
else
{
- clnt_status
+ enum nis_error err
= __follow_path (&tablepath, &tableptr, ibreq, &bptr);
- if (clnt_status != NIS_SUCCESS)
+ if (err != NIS_SUCCESS)
{
- if (clnt_status == NIS_NOMEMORY)
- NIS_RES_STATUS (res) = clnt_status;
+ if (err == NIS_NOMEMORY)
+ NIS_RES_STATUS (res) = err;
++done;
}
}
/* 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;
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)
(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,
(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,
return res;
}
+libnsl_hidden_nolink_def (nis_remove_entry, GLIBC_2_1)
nis_result *
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)
(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)
return res;
}
+libnsl_hidden_nolink_def (nis_next_entry, GLIBC_2_1)