Skip to content

Commit

Permalink
7126 NSS_XbyY_FINI has too much logic for a function-like macro
Browse files Browse the repository at this point in the history
Reviewed by: Albert Lee <trisk@omniti.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Approved by: Robert Mustacchi <rm@joyent.com>
  • Loading branch information
richlowe committed Jul 17, 2016
1 parent 8ee802c commit d88e84f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
5 changes: 2 additions & 3 deletions usr/src/head/nss_dbdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,13 @@ typedef struct {
(str)->h_errno = 0, \
(str)->erange = 0)

#define NSS_XbyY_FINI(str) (\
(str)->returnval == 0 && (str)->erange && (errno = ERANGE), \
(str)->returnval)
#define NSS_XbyY_FINI(str) _nss_XbyY_fini(str)

#define NSS_PACKED_CRED_CHECK(buf, ruid, euid) (\
((nss_pheader_t *)(buf))->p_ruid == (ruid) && \
((nss_pheader_t *)(buf))->p_euid == (euid))

extern void *_nss_XbyY_fini(nss_XbyY_args_t *);
extern char **_nss_netdb_aliases(const char *, int, char *, int);
extern nss_status_t nss_default_key2str(void *, size_t, nss_XbyY_args_t *,
const char *, int, size_t *);
Expand Down
54 changes: 29 additions & 25 deletions usr/src/lib/libc/port/gen/nss_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,24 +1020,20 @@ _nss_status_vec(void)
}

static void
output_loop_diag_a(
int n,
char *dbase,
struct __nsw_lookup_v1 *lkp)

output_loop_diag_a(int n,
char *dbase,
struct __nsw_lookup_v1 *lkp)
{
(void) fprintf(__nss_debug_file,
"NSS_retry(%d): '%s': trying '%s' ... ",
n, dbase, lkp->service_name);
"NSS_retry(%d): '%s': trying '%s' ... ",
n, dbase, lkp->service_name);
(void) fflush(__nss_debug_file);

}

static void
output_loop_diag_b(
nss_status_t res,
struct __nsw_lookup_v1 *lkp)

output_loop_diag_b(nss_status_t res,
struct __nsw_lookup_v1 *lkp)
{
(void) fprintf(__nss_debug_file, "result=");
switch (res) {
Expand Down Expand Up @@ -1072,7 +1068,7 @@ output_loop_diag_b(
break;
case __NSW_TRYAGAIN_NTIMES:
(void) fprintf(__nss_debug_file, "TRYAGAIN_NTIMES (N=%d)",
lkp->max_retries);
lkp->max_retries);
break;
case __NSW_TRYAGAIN_PAUSED:
(void) fprintf(__nss_debug_file, "TRYAGAIN_PAUSED");
Expand Down Expand Up @@ -1150,7 +1146,7 @@ nss_delete(nss_db_root_t *rootp)

nss_status_t
nss_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum,
void *search_args)
void *search_args)
{
nss_status_t res = NSS_UNAVAIL;
struct nss_db_state *s;
Expand Down Expand Up @@ -1310,7 +1306,7 @@ nss_setent(nss_db_root_t *rootp, nss_db_initf_t initf, nss_getent_t *contextpp)

nss_status_t
nss_getent(nss_db_root_t *rootp, nss_db_initf_t initf, nss_getent_t *contextpp,
void *args)
void *args)
{
nss_status_t status;

Expand Down Expand Up @@ -1364,7 +1360,7 @@ end_iter_u(nss_db_root_t *rootp, struct nss_getent_context *contextp)

static void
nss_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp)
nss_getent_t *contextpp)
{
nss_status_t status;
struct nss_db_state *s;
Expand Down Expand Up @@ -1449,7 +1445,7 @@ nss_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf,

static nss_status_t
nss_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp, void *args)
nss_getent_t *contextpp, void *args)
{
nss_status_t status;
struct nss_db_state *s;
Expand Down Expand Up @@ -1533,7 +1529,7 @@ nss_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
/*ARGSUSED*/
static void
nss_endent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp)
nss_getent_t *contextpp)
{
nss_status_t status;
struct nss_getent_context *contextp;
Expand Down Expand Up @@ -1654,7 +1650,7 @@ nss_pack_dbd(void *buffer, size_t bufsize, nss_db_params_t *p, size_t *poff)
/*ARGSUSED*/
nss_status_t
nss_pack(void *buffer, size_t bufsize, nss_db_root_t *rootp,
nss_db_initf_t initf, int search_fnum, void *search_args)
nss_db_initf_t initf, int search_fnum, void *search_args)
{
nss_pheader_t *pbuf = (nss_pheader_t *)buffer;
nss_XbyY_args_t *in = (nss_XbyY_args_t *)search_args;
Expand Down Expand Up @@ -1762,7 +1758,7 @@ nss_pack(void *buffer, size_t bufsize, nss_db_root_t *rootp,
/*ARGSUSED*/
nss_status_t
nss_pack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp,
nss_db_initf_t initf, nss_getent_t *contextpp)
nss_db_initf_t initf, nss_getent_t *contextpp)
{
nss_pheader_t *pbuf = (nss_pheader_t *)buffer;
struct nss_getent_context *contextp = contextpp->ctx;
Expand Down Expand Up @@ -1836,7 +1832,7 @@ nss_pack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp,
/*ARGSUSED*/
nss_status_t
nss_unpack(void *buffer, size_t bufsize, nss_db_root_t *rootp,
nss_db_initf_t initf, int search_fnum, void *search_args)
nss_db_initf_t initf, int search_fnum, void *search_args)
{
nss_pheader_t *pbuf = (nss_pheader_t *)buffer;
nss_XbyY_args_t *in = (nss_XbyY_args_t *)search_args;
Expand Down Expand Up @@ -1937,7 +1933,7 @@ nss_unpack(void *buffer, size_t bufsize, nss_db_root_t *rootp,
/*ARGSUSED*/
nss_status_t
nss_unpack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp,
nss_db_initf_t initf, nss_getent_t *contextpp, void *args)
nss_db_initf_t initf, nss_getent_t *contextpp, void *args)
{
nss_pheader_t *pbuf = (nss_pheader_t *)buffer;
nss_XbyY_args_t *in = (nss_XbyY_args_t *)args;
Expand Down Expand Up @@ -2009,7 +2005,7 @@ nss_unpack_ent(void *buffer, size_t bufsize, nss_db_root_t *rootp,

nss_status_t
_nsc_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum,
void *search_args)
void *search_args)
{
nss_pheader_t *pbuf;
void *doorptr = NULL;
Expand Down Expand Up @@ -2084,7 +2080,7 @@ _nsc_search(nss_db_root_t *rootp, nss_db_initf_t initf, int search_fnum,
*/
nss_status_t
_nsc_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp)
nss_getent_t *contextpp)
{
nss_status_t status = NSS_TRYLOCAL;
struct nss_getent_context *contextp = contextpp->ctx;
Expand Down Expand Up @@ -2161,7 +2157,7 @@ _nsc_setent_u(nss_db_root_t *rootp, nss_db_initf_t initf,

nss_status_t
_nsc_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp, void *args)
nss_getent_t *contextpp, void *args)
{
nss_status_t status = NSS_TRYLOCAL;
struct nss_getent_context *contextp = contextpp->ctx;
Expand Down Expand Up @@ -2228,7 +2224,7 @@ _nsc_getent_u(nss_db_root_t *rootp, nss_db_initf_t initf,

nss_status_t
_nsc_endent_u(nss_db_root_t *rootp, nss_db_initf_t initf,
nss_getent_t *contextpp)
nss_getent_t *contextpp)
{
nss_status_t status = NSS_TRYLOCAL;
struct nss_getent_context *contextp = contextpp->ctx;
Expand Down Expand Up @@ -2298,3 +2294,11 @@ _nss_get_bufsizes(int arg)
}
return (__nss_buflen_default);
}

void *
_nss_XbyY_fini(nss_XbyY_args_t *args)
{
if ((args->returnval == NULL) && (args->erange != 0))
errno = ERANGE;
return (args->returnval);
}
1 change: 1 addition & 0 deletions usr/src/lib/libc/port/mapfile-vers
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,7 @@ $endif
nss_search;
nss_setent;
_nss_XbyY_fgets;
_nss_XbyY_fini;
__nsw_extended_action_v1;
__nsw_freeconfig_v1;
__nsw_getconfig_v1;
Expand Down

0 comments on commit d88e84f

Please sign in to comment.