diff options
author | Rich Megginson <rmeggins@redhat.com> | 2010-08-31 21:17:30 -0600 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2010-09-01 17:08:30 -0600 |
commit | ea408efe551ad837b08423f6d32b5433ab8dfe2b (patch) | |
tree | 0e8d7a4132d9973498e7746cefdfcfb3f97a386f /lib | |
parent | 19c62472381cf72bc7bd20694bbd672edde7f94f (diff) | |
download | ds-ea408efe551ad837b08423f6d32b5433ab8dfe2b.tar.gz ds-ea408efe551ad837b08423f6d32b5433ab8dfe2b.tar.xz ds-ea408efe551ad837b08423f6d32b5433ab8dfe2b.zip |
fix compiler warnings - unused vars/funcs, invalid casts
This commit fixes many compiler warnings, mostly for things like unused
variables, functions, goto labels.
One place was using csngen_free instead of csn_free. A couple of places
were using casts incorrectly, and several places needed some casts added.
Tested on: RHEL5 x86_64, Fedora 14 x86_64
Reviewed by: nkinder (Thanks!)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base/crit.cpp | 6 | ||||
-rw-r--r-- | lib/base/ereport.cpp | 2 | ||||
-rw-r--r-- | lib/base/util.cpp | 3 | ||||
-rw-r--r-- | lib/ldaputil/certmap.c | 212 | ||||
-rw-r--r-- | lib/libaccess/aclcache.cpp | 1 | ||||
-rw-r--r-- | lib/libaccess/aclflush.cpp | 1 | ||||
-rw-r--r-- | lib/libaccess/aclpriv.h | 1 | ||||
-rw-r--r-- | lib/libaccess/authdb.cpp | 112 | ||||
-rw-r--r-- | lib/libaccess/oneeval.cpp | 1 | ||||
-rw-r--r-- | lib/libaccess/permhash.h | 11 | ||||
-rw-r--r-- | lib/libaccess/register.cpp | 1 |
11 files changed, 6 insertions, 345 deletions
diff --git a/lib/base/crit.cpp b/lib/base/crit.cpp index 1a1286c2..2aa9b5ac 100644 --- a/lib/base/crit.cpp +++ b/lib/base/crit.cpp @@ -56,13 +56,7 @@ #include "crit.h" #include "pool.h" -#include "base/dbtbase.h" - #ifdef USE_NSPR -/* -#include "prmon.h" -#include "private/primpl.h" -*/ #include "nspr.h" #include "prthread.h" diff --git a/lib/base/ereport.cpp b/lib/base/ereport.cpp index ba3df4e5..e6b77685 100644 --- a/lib/base/ereport.cpp +++ b/lib/base/ereport.cpp @@ -54,8 +54,6 @@ #include "ereport.h" #include "slapi-plugin.h" -#include "base/dbtbase.h" - #include <stdarg.h> #include <stdio.h> /* vsprintf */ #include <string.h> /* strcpy */ diff --git a/lib/base/util.cpp b/lib/base/util.cpp index d3a7c330..b198154e 100644 --- a/lib/base/util.cpp +++ b/lib/base/util.cpp @@ -56,9 +56,6 @@ #include "base/util.h" -#include "base/dbtbase.h" - - #ifdef XP_UNIX #include <sys/types.h> #endif /* WIN32 */ diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c index a8cb6cb2..9c6b2bad 100644 --- a/lib/ldaputil/certmap.c +++ b/lib/ldaputil/certmap.c @@ -234,94 +234,6 @@ NSAPI_PUBLIC int ldapu_list_add_info (LDAPUList_t *list, void *info) return ldapu_list_add_node(list, node); } -static int ldapu_list_remove_node (LDAPUList_t *list, LDAPUListNode_t *node) -{ - if (list->head == node) { - list->head = node->next; - if (list->tail == node) list->tail = 0; /* removed the only node */ - } - else if (list->tail == node) { - list->tail = node->prev; - } - else { - node->prev->next = node->next; - node->next->prev = node->prev; - } - - node->next = 0; - node->prev = 0; - return LDAPU_SUCCESS; -} - -static int ldapu_list_copy (const LDAPUList_t *from, LDAPUList_t **to, - LDAPUListNodeFn_t copy_fn) -{ - LDAPUListNode_t *node = from->head; - LDAPUListNode_t *newnode; - LDAPUList_t *list = NULL; - int rv; - - *to = 0; - rv = ldapu_list_alloc(&list); - if (rv != LDAPU_SUCCESS) goto error; - - while(node) { - newnode = (LDAPUListNode_t *)(*copy_fn)(node->info, 0); - if (!newnode) { - rv = LDAPU_ERR_OUT_OF_MEMORY; - goto error; - } - - rv = ldapu_list_add_info(list, newnode); - if (rv != LDAPU_SUCCESS) goto error; - - node = node->next; - } - - *to = list; - goto done; - -error: - if (list) ldapu_propval_list_free(list); - -done: - return rv; -} - -static int ldapu_list_find_node (const LDAPUList_t *list, - LDAPUListNode_t **found, - LDAPUListNodeFn_t find_fn, - void *find_arg) -{ - LDAPUListNode_t *node = list->head; - - while(node) { - if ((*find_fn)(node->info, find_arg) == LDAPU_SUCCESS) { - *found = node; - return LDAPU_SUCCESS; - } - node = node->next; - } - - return LDAPU_ERR_CERTMAP_INFO_MISSING; -} - -static int ldapu_list_print (LDAPUList_t *list, LDAPUListNodeFn_t print_fn, - LDAPUPrintInfo_t *pinfo) -{ - LDAPUListNode_t *node = list->head; - int rv; - - while(node) { - uintptr_t retval = (uintptr_t)(*print_fn)(node->info, pinfo); - rv = (int)retval; - if (rv != LDAPU_SUCCESS) return rv; - node = node->next; - } - - return LDAPU_SUCCESS; -} - static void ldapu_list_free (LDAPUList_t *list, LDAPUListNodeFn_t free_fn) { @@ -362,44 +274,6 @@ NSAPI_PUBLIC int ldapu_propval_alloc (const char *prop, const char *val, } } -static void *ldapu_propval_copy (void *info, void *arg) -{ - LDAPUPropVal_t *propval = (LDAPUPropVal_t *)info; - LDAPUPropVal_t *copy = 0; - int rv; - - rv = ldapu_propval_alloc(propval->prop, propval->val, ©); - - if (rv != LDAPU_SUCCESS) { - if (copy) ldapu_propval_free(copy, 0); - return 0; - } - - return copy; -} - -#define PRINT_STR(x) (x ? x : "<NULL>") - -static void * ldapu_propval_print (void *info, void *arg) -{ - LDAPUPropVal_t *propval = (LDAPUPropVal_t *)info; - LDAPUPrintInfo_t *pinfo = (LDAPUPrintInfo_t *)arg; - - if (!pinfo || !pinfo->fp) { - fprintf(stderr, "\tprop = \"%s\", \tval = \"%s\"\n", - PRINT_STR(propval->prop), - PRINT_STR(propval->val)); - } - else { - char *issuerName = (char *)pinfo->arg; - - fprintf(pinfo->fp, "%s:%s %s\n", issuerName, - propval->prop ? propval->prop : "", - propval->val ? propval->val : ""); - } - - return 0; -} static int PresentInComps (long comps_bitmask, int tag) { @@ -411,79 +285,6 @@ static int PresentInComps (long comps_bitmask, int tag) return 0; } -static void print_oid_bitmask (long bitmask) -{ - fprintf(stderr, "%lx: ", bitmask); - - if (PresentInComps(bitmask, SEC_OID_AVA_COUNTRY_NAME)) - fprintf(stderr, " C"); - if (PresentInComps(bitmask, SEC_OID_AVA_ORGANIZATION_NAME)) - fprintf(stderr, " O"); - if (PresentInComps(bitmask, SEC_OID_AVA_COMMON_NAME)) - fprintf(stderr, " CN"); - if (PresentInComps(bitmask, SEC_OID_AVA_LOCALITY)) - fprintf(stderr, " L"); - if (PresentInComps(bitmask, SEC_OID_AVA_STATE_OR_PROVINCE)) - fprintf(stderr, " ST"); - if (PresentInComps(bitmask, SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME)) - fprintf(stderr, " OU"); - if (PresentInComps(bitmask, SEC_OID_PKCS9_EMAIL_ADDRESS)) - fprintf(stderr, " E"); - if (PresentInComps(bitmask, SEC_OID_RFC1274_UID)) - fprintf(stderr, " UID"); - if (PresentInComps(bitmask, SEC_OID_RFC1274_MAIL)) - fprintf(stderr, " MAIL"); - if (PresentInComps(bitmask, SEC_OID_AVA_DC)) - fprintf(stderr, " DC"); - /* check for not yet known oid */ - if (PresentInComps(bitmask, 34325)) - fprintf(stderr, " UNKNOWN"); - - fprintf(stderr, "\n"); -} - -static void *ldapu_certinfo_print (void *info, void *arg) -{ - LDAPUCertMapInfo_t *certinfo = (LDAPUCertMapInfo_t*)info; - LDAPUPrintInfo_t *pinfo = (LDAPUPrintInfo_t *)arg; - - if (!certinfo) return (void *)LDAPU_ERR_WRONG_ARGS; - - if (!pinfo || !pinfo->fp) { - fprintf(stderr, "Printing cert mapinfo: \"%s\" ...\n", - PRINT_STR(certinfo->issuerName)); - fprintf(stderr, "\tissuerDN = \"%s\"\n", - PRINT_STR(certinfo->issuerDN)); - fprintf(stderr, "\tParsed dncomps: "); - print_oid_bitmask(certinfo->dncomps); - fprintf(stderr, "\tParsed filtercomps: "); - print_oid_bitmask(certinfo->filtercomps); - - if (certinfo->propval) { - fprintf(stderr, "\tPrinting propval pairs: ...\n"); - if (certinfo->propval) - ldapu_list_print(certinfo->propval, ldapu_propval_print, pinfo); - } - else { - fprintf(stderr, "\tNo propval pairs\n"); - } - } - else { - LDAPUPrintInfo_t pinfo2; - - pinfo2.fp = pinfo->fp; - pinfo2.arg = certinfo->issuerName; - - /* Write certinfo to pinfo->fp */ - fprintf(pinfo->fp, "%s %s %s\n", LIB_DIRECTIVE, certinfo->issuerName, - certinfo->issuerDN ? certinfo->issuerDN : ""); - if (certinfo->propval) - ldapu_list_print(certinfo->propval, ldapu_propval_print, &pinfo2); - fprintf(pinfo->fp, "\n"); - } - - return (void *)LDAPU_SUCCESS; -} static int dbconf_to_certmap_err (int err) { @@ -1631,19 +1432,6 @@ done: return rv; } -/* ldapu_propval_same - returns LDAPU_SUCCESS or LDAPU_FAILED */ -static void * ldapu_propval_same (void *info, void *find_arg) -{ - /* check if info has find_arg as the issuerDN */ - const char *issuerDN = (const char *)find_arg; - const LDAPUCertMapInfo_t *certinfo = (const LDAPUCertMapInfo_t *) info; - - if (!ldapu_strcasecmp(certinfo->issuerDN, issuerDN)) - return (void *)LDAPU_SUCCESS; - else - return (void *)LDAPU_FAILED; -} - static void * ldapu_propval_free (void *propval_in, void *arg) { LDAPUPropVal_t *propval = (LDAPUPropVal_t *)propval_in; diff --git a/lib/libaccess/aclcache.cpp b/lib/libaccess/aclcache.cpp index 10588879..f814df7c 100644 --- a/lib/libaccess/aclcache.cpp +++ b/lib/libaccess/aclcache.cpp @@ -52,6 +52,7 @@ #include <libaccess/usrcache.h> #include <libaccess/las.h> #include "aclutil.h" +#define NO_ACL_HASH_FUNCS #include "permhash.h" #include "aclcache.h" diff --git a/lib/libaccess/aclflush.cpp b/lib/libaccess/aclflush.cpp index 8e5ce7c8..a2f44618 100644 --- a/lib/libaccess/aclflush.cpp +++ b/lib/libaccess/aclflush.cpp @@ -52,7 +52,6 @@ #include <libaccess/aclglobal.h> #include <libaccess/las.h> #include "aclcache.h" -#include <libaccess/dbtlibaccess.h> extern void ACL_DatabaseDestroy(void); diff --git a/lib/libaccess/aclpriv.h b/lib/libaccess/aclpriv.h index a95b3637..8744ef02 100644 --- a/lib/libaccess/aclpriv.h +++ b/lib/libaccess/aclpriv.h @@ -61,6 +61,7 @@ #define ACL_MIN_IDX 0 #define ACL_EXPR_STACK 1024 #define ACL_TABLE_THRESHOLD 10 +#define ACL_NO_UNPUT 1 /* unput is not used and causes compiler warnings */ typedef enum { ACL_EXPR_OP_AND, diff --git a/lib/libaccess/authdb.cpp b/lib/libaccess/authdb.cpp index da435c39..4196c3ab 100644 --- a/lib/libaccess/authdb.cpp +++ b/lib/libaccess/authdb.cpp @@ -47,7 +47,6 @@ #include <plhash.h> #include <netsite.h> -#include "permhash.h" #include <ldaputil/errors.h> #include <ldaputil/certmap.h> #include <ldaputil/dbconf.h> @@ -250,117 +249,6 @@ NSAPI_PUBLIC int ACL_DatabaseFind(NSErr_t *errp, const char *name, return LAS_EVAL_FAIL; } - -NSAPI_PUBLIC int ACL_ReadDbMapFile (NSErr_t *errp, const char *map_file, - int default_only) -{ - DBConfInfo_t *info; - DBConfDBInfo_t *db_info; - DBPropVal_t *propval; - PList_t plist; - int rv; - int seen_default = 0; - - if (default_only) - rv = dbconf_read_default_dbinfo(map_file, &db_info); - else - rv = dbconf_read_config_file(map_file, &info); - - if (rv != LDAPU_SUCCESS) { - nserrGenerate(errp, ACLERRFAIL, ACLERR4600, ACL_Program, 3, XP_GetAdminStr(DBT_ReadDbMapFileErrorReadingFile), map_file, ldapu_err2string(rv)); - return -1; - } - - rv = 0; - - if (!default_only) - db_info = info->firstdb; - - while(db_info) { - char *url = db_info->url; - char *dbname = db_info->dbname; - ACLDbType_t dbtype; - - /* process db_info */ - if (url) { - rv = acl_url_to_dbtype(url, &dbtype); - - if (rv < 0) { - nserrGenerate(errp, ACLERRFAIL, ACLERR4610, ACL_Program, 2, - XP_GetAdminStr(DBT_ReadDbMapFileCouldntDetermineDbtype), url); - break; - } - } - else { - nserrGenerate(errp, ACLERRFAIL, ACLERR4620, ACL_Program, 2, - XP_GetAdminStr(DBT_ReadDbMapFileMissingUrl), dbname); - rv = -1; - break; - } - - /* convert any property-value pairs in db_info into plist */ - plist = PListNew(NULL); - propval = db_info->firstprop; - - while(propval) { - if (propval->prop) { - PListInitProp(plist, 0, propval->prop, propval->val, 0); - } - else { - nserrGenerate(errp, ACLERRINVAL, ACLERR4630, ACL_Program, 2, - XP_GetAdminStr(DBT_ReadDbMapFileInvalidPropertyPair), dbname); - rv = -1; - break; - } - propval = propval->next; - } - - if (rv < 0) break; - - /* register the database */ - rv = ACL_DatabaseRegister(errp, dbtype, dbname, url, plist); - PListDestroy(plist); - - if (rv < 0) { - /* Failed to register database */ - nserrGenerate(errp, ACLERRFAIL, ACLERR4640, ACL_Program, 2, - XP_GetAdminStr(DBT_ReadDbMapFileRegisterDatabaseFailed), dbname); - break; - } - - /* If the dbname is "default", set the default_dbtype */ - if (!strcmp(dbname, DBCONF_DEFAULT_DBNAME)) { - if (!ACL_DbTypeIsEqual(errp, dbtype, ACL_DbTypeLdap)) { - nserrGenerate(errp, ACLERRINVAL, ACLERR4350, ACL_Program, 1, - XP_GetAdminStr(DBT_ReadDbMapFileDefaultDatabaseNotLdap)); - rv = -1; - break; - } - if (seen_default) { - nserrGenerate(errp, ACLERRINVAL, ACLERR4360, ACL_Program, 1, XP_GetAdminStr(DBT_ReadDbMapFileMultipleDefaultDatabases)); - rv = -1; - break; - } - seen_default = 1; - ACL_DatabaseSetDefault(errp, dbname); - } - - db_info = db_info->next; - } - - if (!seen_default) { - nserrGenerate(errp, ACLERRINVAL, ACLERR4370, ACL_Program, 1, XP_GetAdminStr(DBT_ReadDbMapFileMissingDefaultDatabase)); - rv = -1; - } - - if (default_only) - dbconf_free_dbinfo(db_info); - else - dbconf_free_confinfo(info); - - return rv; -} - void ACL_DatabaseDestroy(void) { diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp index 8056e0ec..ed29ee47 100644 --- a/lib/libaccess/oneeval.cpp +++ b/lib/libaccess/oneeval.cpp @@ -70,6 +70,7 @@ #include "aclutil.h" #include "aclcache.h" #include "oneeval.h" +#define NO_ACL_HASH_FUNCS #include "permhash.h" static ACLDispatchVector_t __nsacl_vector = { diff --git a/lib/libaccess/permhash.h b/lib/libaccess/permhash.h index f76ab4c6..9446fb55 100644 --- a/lib/libaccess/permhash.h +++ b/lib/libaccess/permhash.h @@ -80,13 +80,7 @@ static PLHashAllocOps ACLPermAllocOps = { ACL_PermFreeEntry }; -static int -PR_StringFree(PLHashEntry *he, int i, void *arg) -{ - PERM_FREE(he->key); - return 0; -} - +#ifndef NO_ACL_HASH_FUNCS static PLHashNumber PR_HashCaseString(const void *key) { @@ -111,6 +105,7 @@ PR_CompareCaseStrings(const void *v1, const void *v2) return (strcasecmp(s1, s2) == 0); #endif } - +#endif /* NO_ACL_HASH_FUNCS */ + #endif /* _PERMHASH_H */ diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp index 09d918fc..3f2acc5e 100644 --- a/lib/libaccess/register.cpp +++ b/lib/libaccess/register.cpp @@ -56,7 +56,6 @@ #include <libaccess/aclproto.h> #include <libaccess/aclglobal.h> #include "aclcache.h" -#include <libaccess/dbtlibaccess.h> #include <libaccess/aclerror.h> /* This is to force aclspace.o into ns-httpd30.dll */ |