mirror of git://sourceware.org/git/glibc.git
* nis/nis_table.c (__create_ib_request): Use strdupa instead of
variable size array. (RPCTIMEOUT): Mark as const. (RPCTIMEOUT, UDPTIMEOUT): Mark as const.
This commit is contained in:
parent
d9fc1ec727
commit
3218d55b95
|
@ -1,5 +1,9 @@
|
||||||
2005-11-26 Ulrich Drepper <drepper@redhat.com>
|
2005-11-26 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nis/nis_table.c (__create_ib_request): Use strdupa instead of
|
||||||
|
variable size array.
|
||||||
|
(RPCTIMEOUT): Mark as const.
|
||||||
|
|
||||||
* nis/ypclnt.c (yp_bind_ypbindprog): Initialize clnt_saddr by hand.
|
* nis/ypclnt.c (yp_bind_ypbindprog): Initialize clnt_saddr by hand.
|
||||||
(ypdomainname): Renamed from __ypdomainname. No need for initializer.
|
(ypdomainname): Renamed from __ypdomainname. No need for initializer.
|
||||||
(ypbindlist): Renamed from __ypbindlist.
|
(ypbindlist): Renamed from __ypbindlist.
|
||||||
|
@ -15,6 +19,7 @@
|
||||||
(yp_match, yp_next, yp_master, yp_order, yp_maplist): Use it.
|
(yp_match, yp_next, yp_master, yp_order, yp_maplist): Use it.
|
||||||
(yp_all): Correct test for invalid parameter.
|
(yp_all): Correct test for invalid parameter.
|
||||||
Pretty printing.
|
Pretty printing.
|
||||||
|
(RPCTIMEOUT, UDPTIMEOUT): Mark as const.
|
||||||
|
|
||||||
2005-11-25 Richard Henderson <rth@redhat.com>
|
2005-11-25 Richard Henderson <rth@redhat.com>
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,9 @@
|
||||||
static struct ib_request *
|
static struct ib_request *
|
||||||
__create_ib_request (const_nis_name name, unsigned int flags)
|
__create_ib_request (const_nis_name name, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct ib_request *ibreq = calloc (1, sizeof (ib_request));
|
struct ib_request *ibreq = calloc (1, sizeof (struct ib_request));
|
||||||
char buf[strlen (name) + 1];
|
|
||||||
nis_attr *search_val = NULL;
|
nis_attr *search_val = NULL;
|
||||||
size_t search_len = 0;
|
size_t search_len = 0;
|
||||||
char *cptr;
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
if (ibreq == NULL)
|
if (ibreq == NULL)
|
||||||
|
@ -39,7 +37,7 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
||||||
|
|
||||||
ibreq->ibr_flags = flags;
|
ibreq->ibr_flags = flags;
|
||||||
|
|
||||||
cptr = strcpy (buf, name);
|
char *cptr = strdupa (name);
|
||||||
|
|
||||||
/* Not of "[key=value,key=value,...],foo.." format? */
|
/* Not of "[key=value,key=value,...],foo.." format? */
|
||||||
if (cptr[0] != '[')
|
if (cptr[0] != '[')
|
||||||
|
@ -49,8 +47,8 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
||||||
ibreq->ibr_name = strchr (cptr, ']');
|
ibreq->ibr_name = strchr (cptr, ']');
|
||||||
if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',')
|
if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',')
|
||||||
{
|
{
|
||||||
ibreq->ibr_name = NULL; /* Or the xdr_* functions will dump */
|
/* The object has not really been built yet so we use free. */
|
||||||
nis_free_request (ibreq);
|
free (ibreq);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,17 +118,16 @@ __create_ib_request (const_nis_name name, unsigned int flags)
|
||||||
return ibreq;
|
return ibreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct timeval RPCTIMEOUT = {10, 0};
|
static const struct timeval RPCTIMEOUT = {10, 0};
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
__get_tablepath (char *name, dir_binding *bptr)
|
__get_tablepath (char *name, dir_binding *bptr)
|
||||||
{
|
{
|
||||||
enum clnt_stat result;
|
enum clnt_stat result;
|
||||||
nis_result *res = calloc (1, sizeof (nis_result));
|
nis_result res;
|
||||||
struct ns_request req;
|
struct ns_request req;
|
||||||
|
|
||||||
if (res == NULL)
|
memset (&res, '\0', sizeof (res));
|
||||||
return NULL;
|
|
||||||
|
|
||||||
req.ns_name = name;
|
req.ns_name = name;
|
||||||
req.ns_object.ns_object_len = 0;
|
req.ns_object.ns_object_len = 0;
|
||||||
|
@ -138,20 +135,16 @@ __get_tablepath (char *name, dir_binding *bptr)
|
||||||
|
|
||||||
result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request,
|
result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request,
|
||||||
(caddr_t) &req, (xdrproc_t) _xdr_nis_result,
|
(caddr_t) &req, (xdrproc_t) _xdr_nis_result,
|
||||||
(caddr_t) res, RPCTIMEOUT);
|
(caddr_t) &res, RPCTIMEOUT);
|
||||||
|
|
||||||
if (result == RPC_SUCCESS && NIS_RES_STATUS (res) == NIS_SUCCESS &&
|
char *cptr;
|
||||||
__type_of (NIS_RES_OBJECT (res)) == NIS_TABLE_OBJ)
|
if (result == RPC_SUCCESS && NIS_RES_STATUS (&res) == NIS_SUCCESS
|
||||||
{
|
&& __type_of (NIS_RES_OBJECT (&res)) == NIS_TABLE_OBJ)
|
||||||
char *cptr = strdup (NIS_RES_OBJECT (res)->TA_data.ta_path);
|
cptr = NIS_RES_OBJECT (&res)->TA_data.ta_path;
|
||||||
nis_freeresult (res);
|
|
||||||
return cptr;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
cptr = "";
|
||||||
nis_freeresult (res);
|
|
||||||
return strdup ("");
|
return strdup (cptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nis_result *
|
nis_result *
|
||||||
|
|
|
@ -46,8 +46,8 @@ struct dom_binding
|
||||||
};
|
};
|
||||||
typedef struct dom_binding dom_binding;
|
typedef struct dom_binding dom_binding;
|
||||||
|
|
||||||
static struct timeval RPCTIMEOUT = {25, 0};
|
static const struct timeval RPCTIMEOUT = {25, 0};
|
||||||
static struct timeval UDPTIMEOUT = {5, 0};
|
static const struct timeval UDPTIMEOUT = {5, 0};
|
||||||
static int const MAXTRIES = 2;
|
static int const MAXTRIES = 2;
|
||||||
static char ypdomainname[NIS_MAXNAMELEN + 1];
|
static char ypdomainname[NIS_MAXNAMELEN + 1];
|
||||||
__libc_lock_define_initialized (static, ypbindlist_lock)
|
__libc_lock_define_initialized (static, ypbindlist_lock)
|
||||||
|
|
Loading…
Reference in New Issue