From aee36002767937f0dfe7382270979f0827fcf072 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 17 Nov 2001 16:18:07 +0000 Subject: [PATCH] minor cleanup --- servers/slapd/attr.c | 2 +- servers/slapd/back-monitor/conn.c | 1 - servers/slapd/back-monitor/init.c | 2 +- servers/slapd/back-monitor/search.c | 7 ++++--- servers/slapd/bind.c | 4 ++-- servers/slapd/compare.c | 1 - servers/slapd/config.c | 4 ++-- servers/slapd/connection.c | 6 ++++++ servers/slapd/daemon.c | 8 ++++---- servers/slapd/dn.c | 4 ++++ servers/slapd/entry.c | 1 - servers/slapd/main.c | 7 ++++++- servers/slapd/proto-slap.h | 4 ++-- servers/slapd/referral.c | 2 ++ servers/slapd/root_dse.c | 3 +-- servers/slapd/sasl.c | 8 ++++---- servers/slapd/schema_init.c | 8 +++----- servers/slapd/schemaparse.c | 1 - servers/slapd/sets.c | 4 ++-- servers/slapd/starttls.c | 2 ++ servers/slapd/user.c | 4 ++-- servers/slapd/value.c | 1 - 22 files changed, 48 insertions(+), 36 deletions(-) diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index d5b9e3a078..99d1e3bb87 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -23,7 +23,7 @@ #include "slap.h" #ifdef LDAP_DEBUG -static void at_index_print( void ); +static void at_index_print( void ) {}; #endif void diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 84283a579f..ff65b7503b 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -48,7 +48,6 @@ monitor_subsys_conn_init( { struct monitorinfo *mi; - char buf[1024]; Entry *e; struct berval *bv[2], val; diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 761090a69f..e787577556 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -310,7 +310,7 @@ monitor_back_db_init( "cn: Monitor\n" "description: %s", SLAPD_MONITOR_DN, - (char *) Versionstr + /* (char *) Versionstr */ "slapd 2.0" ); e = str2entry( buf ); if ( e == NULL) { diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index 4df70ae71f..27b9fb5efc 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -61,6 +61,7 @@ monitor_send_children( struct monitorinfo *mi = (struct monitorinfo *) be->be_private; Entry *e, *e_tmp; struct monitorentrypriv *mp; + int nentries; int rc; mp = ( struct monitorentrypriv * )e_parent->e_private; @@ -74,7 +75,7 @@ monitor_send_children( } monitor_cache_release( mi, e_parent ); - for ( ; e != NULL; ) { + for ( nentries = *nentriesp; e != NULL; ) { mp = ( struct monitorentrypriv * )e->e_private; monitor_entry_update( mi, e ); @@ -83,14 +84,14 @@ monitor_send_children( if ( rc == LDAP_COMPARE_TRUE ) { send_search_entry( be, conn, op, e, attrs, attrsonly, NULL ); - *nentriesp++; + nentries++; } if ( ( mp->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) ) && sub ) { rc = monitor_send_children( be, conn, op, filter, attrs, attrsonly, - e, sub, nentriesp ); + e, sub, &nentries ); if ( rc ) { return( rc ); } diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 6480cf7fb8..6378d78ddf 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -412,11 +412,11 @@ do_bind( NULL, text, NULL, NULL ); #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, - "do_bind: conn %d v%d unknown authentication method (%d)\n", + "do_bind: conn %ld v%d unknown authentication method (%ld)\n", conn->c_connid, version, method )); #else Debug( LDAP_DEBUG_TRACE, - "do_bind: v%d unknown authentication method (%d)\n", + "do_bind: v%d unknown authentication method (%ld)\n", version, method, 0 ); #endif goto cleanup; diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 77942684c3..693eba8e09 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -36,7 +36,6 @@ do_compare( ) { Entry *entry = NULL; - Attribute *a = NULL; char *dn = NULL, *ndn=NULL; struct berval desc; struct berval value; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index e912ddfe3f..addef851a9 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -865,11 +865,11 @@ read_config( const char *fname ) #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \"%s\" is reserved for monitoring slapd\n", - SLAPD_MONITOR_DN, fname, lineno )); + fname, lineno, SLAPD_MONITOR_DN )); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: \"%s\" is reserved for monitoring slapd\n", - SLAPD_MONITOR_DN, fname, lineno ); + fname, lineno, SLAPD_MONITOR_DN ); #endif return( 1 ); #endif /* SLAPD_MONITOR_DN */ diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 4d8fa9b3fb..ed8659fd8e 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -14,11 +14,15 @@ #include #include #include +#include #include "ldap_pvt.h" #include "lutil.h" #include "slap.h" +/* I guess this should be declared in ldap_pvt.h */ +extern void * ldap_pvt_tls_sb_ctx( Sockbuf *sb ); + /* protected by connections_mutex */ static ldap_pvt_thread_mutex_t connections_mutex; static Connection *connections = NULL; @@ -1063,8 +1067,10 @@ int connection_read(ber_socket_t s) if ( c->c_is_tls && c->c_needs_tls_accept ) { rc = ldap_pvt_tls_accept( c->c_sb, NULL ); if ( rc < 0 ) { +#if 0 /* required by next #if 0 */ struct timeval tv; fd_set rfd; +#endif #ifdef NEW_LOGGING LDAP_LOG(( "connection", LDAP_LEVEL_ERR, diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index ddb202bfea..e9f0a09509 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -374,7 +374,7 @@ static int slap_get_listener_addresses( hints.ai_family = AF_UNSPEC; snprintf(serv, sizeof serv, "%d", port); - if (err = getaddrinfo(host, serv, &hints, &res)) { + if ( (err = getaddrinfo(host, serv, &hints, &res)) ) { #ifdef NEW_LOGGING LDAP_LOG(( "connection", LDAP_LEVEL_INFO, "slap_get_listener_addresses: getaddrinfo failed: %s\n", @@ -502,7 +502,7 @@ static Listener * slap_open_listener( Listener *li; LDAPURLDesc *lud; unsigned short port; - int err, addrlen; + int err, addrlen = 0; struct sockaddr **sal, **psal; int socktype = SOCK_STREAM; /* default to COTS */ @@ -940,7 +940,7 @@ slapd_daemon_task( ) { int l; - time_t last_idle_check; + time_t last_idle_check = 0; time( &starttime ); if ( global_idletimeout > 0 ) { @@ -1162,7 +1162,7 @@ slapd_daemon_task( slap_ssf_t ssf = 0; char *authid = NULL; - char *dnsname; + char *dnsname = NULL; char *peeraddr; #ifdef LDAP_PF_LOCAL char peername[MAXPATHLEN + sizeof("PATH=")]; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 665600c5c1..780cbb0a50 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -28,6 +28,10 @@ #define INQUOTEDVALUE 7 #define B4SEPARATOR 8 +/* schema_init.c */ +extern int +dnNormalize( Syntax *syntax, struct berval *val, struct berval **normalized ); + /* * dn_validate - validate and compress dn. the dn is * compressed in place are returned if valid. diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index a150097dae..9dd396ffb9 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -41,7 +41,6 @@ str2entry( char *s ) { int rc; Entry *e; - Attribute **a = NULL; char *type; struct berval value; struct berval *vals[2]; diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 8d774984e0..b1beef495d 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -15,10 +15,15 @@ #include #include +#include "ldap_pvt.h" + #include "slap.h" #include "lutil.h" #include "ldif.h" +/* I guess this should be declared in ldap_pvt.h */ +extern int ldap_pvt_tls_init_def_ctx( void ); + #ifdef LDAP_SIGCHLD static RETSIGTYPE wait4child( int sig ); #endif @@ -127,7 +132,7 @@ int main( int argc, char **argv ) #endif { int i, no_detach = 0; - int rc; + int rc = 1; char *urls = NULL; #if defined(HAVE_SETUID) && defined(HAVE_SETGID) char *username = NULL; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index c05a4ed057..ab0999850e 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -842,8 +842,8 @@ LDAP_SLAPD_F (int) krbv4_ldap_auth(); /* * Other... */ -#define SLAP_SB_MAX_INCOMING_DEFAULT (1<<18 - 1) -#define SLAP_SB_MAX_INCOMING_AUTH (1<<24 - 1) +#define SLAP_SB_MAX_INCOMING_DEFAULT ((1<<18) - 1) +#define SLAP_SB_MAX_INCOMING_AUTH ((1<<24) - 1) LDAP_SLAPD_F (ber_len_t) sockbuf_max_incoming; LDAP_SLAPD_F (ber_len_t) sockbuf_max_incoming_auth; diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 178761ee7a..272f945080 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -17,6 +17,8 @@ #include #include +#include + #include "slap.h" /* diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 68166471f8..cacce964e3 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -16,6 +16,7 @@ #include #include "slap.h" +#include static char *supportedFeatures[] = { "1.3.6.1.4.1.4203.1.5.1", /* All Operational Attributes ("+") */ @@ -146,7 +147,6 @@ root_dse_info( int read_root_dse_file( const char *fname ) { FILE *fp; - char *line, *savefname, *saveline; int rc = 0, lineno = 0, lmax = 0; char *buf = NULL; @@ -164,7 +164,6 @@ int read_root_dse_file( const char *fname ) usr_attr->e_attrs = NULL; while( ldif_read_record( fp, &lineno, &buf, &lmax ) ) { - ID id; Entry *e = str2entry( buf ); if( e == NULL ) { diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index f2907b47db..e3fd7fbcd7 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -60,11 +60,11 @@ slap_sasl_log( #ifdef NEW_LOGGING LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "SASL [conn=%d] %s: %s\n", + "SASL [conn=%ld] %s: %s\n", conn ? conn->c_connid : -1, label, message )); #else - Debug( level, "SASL [conn=%d] %s: %s\n", + Debug( level, "SASL [conn=%ld] %s: %s\n", conn ? conn->c_connid: -1, label, message ); #endif @@ -617,13 +617,13 @@ int slap_sasl_bind( #ifdef NEW_LOGGING LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY, - "sasl_bind: conn %ld dn=\"%s\" mech=%s datalen=%d\n", + "sasl_bind: conn %ld dn=\"%s\" mech=%s datalen=%ld\n", conn->c_connid, dn, conn->c_sasl_bind_in_progress ? "" : conn->c_sasl_bind_mech, cred ? cred->bv_len : 0 )); #else Debug(LDAP_DEBUG_ARGS, - "==> sasl_bind: dn=\"%s\" mech=%s datalen=%d\n", dn, + "==> sasl_bind: dn=\"%s\" mech=%s datalen=%ld\n", dn, conn->c_sasl_bind_in_progress ? "":conn->c_sasl_bind_mech, cred ? cred->bv_len : 0 ); #endif diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index afc942761c..827f878d99 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1104,7 +1104,7 @@ caseExactIgnoreSubstringsMatch( void *assertedValue ) { int match = 0; - SubstringsAssertion *sub; + SubstringsAssertion *sub = NULL; struct berval left; int i; ber_len_t inlen=0; @@ -3530,7 +3530,6 @@ asn1_integer2str(ASN1_INTEGER *a) */ while (base < n) { unsigned int carry; - unsigned int temp; carry = 0; for (i = base; ibv_len); if ( !xcert ) { @@ -4090,7 +4088,7 @@ utcTimeNormalize( return LBER_ERROR_MEMORY; } - sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ldZ", + sprintf( out->bv_val, "%02d%02d%02d%02d%02d%02dZ", parts[1], parts[2] + 1, parts[3] + 1, parts[4], parts[5], parts[6] ); out->bv_len = 13; @@ -4145,7 +4143,7 @@ generalizedTimeNormalize( return LBER_ERROR_MEMORY; } - sprintf( out->bv_val, "%02ld%02ld%02ld%02ld%02ld%02ld%02ldZ", + sprintf( out->bv_val, "%02d%02d%02d%02d%02d%02d%02dZ", parts[0], parts[1], parts[2] + 1, parts[3] + 1, parts[4], parts[5], parts[6] ); out->bv_len = 15; diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 22cb966ece..e969e9b390 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -293,7 +293,6 @@ parse_at( int code; const char *err; char *oid = NULL; - char *soid = NULL; at = ldap_str2attributetype(line,&code,&err,LDAP_SCHEMA_ALLOW_ALL); if ( !at ) { diff --git a/servers/slapd/sets.c b/servers/slapd/sets.c index 7dc7507947..768edbd317 100644 --- a/servers/slapd/sets.c +++ b/servers/slapd/sets.c @@ -219,7 +219,7 @@ set_filter (SET_GATHER gatherer, *results = NULL; stp = -1; - while (c = *filter++) { + while ((c = *filter++)) { set = NULL; switch (c) { case ' ': @@ -390,7 +390,7 @@ set_filter (SET_GATHER gatherer, _error: if (IS_SET(set)) set_dispose(set); - while (set = SF_POP()) { + while ((set = SF_POP())) { if (IS_SET(set)) set_dispose(set); } diff --git a/servers/slapd/starttls.c b/servers/slapd/starttls.c index b5582e7652..335213b5af 100644 --- a/servers/slapd/starttls.c +++ b/servers/slapd/starttls.c @@ -14,6 +14,8 @@ #include #include +#include + #include "slap.h" #ifdef HAVE_TLS diff --git a/servers/slapd/user.c b/servers/slapd/user.c index 23cd431a6d..05b859b5ea 100644 --- a/servers/slapd/user.c +++ b/servers/slapd/user.c @@ -43,8 +43,8 @@ void slap_init_user( char *user, char *group ) { - uid_t uid; - gid_t gid; + uid_t uid = 0; + gid_t gid = 0; int got_uid = 0, got_gid = 0; if ( user ) { diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 0508b3590d..c73807cebf 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -134,7 +134,6 @@ value_match( int rc; struct berval *nv1 = NULL; struct berval *nv2 = NULL; - Syntax *syntax; if( !mr->smr_match ) { return LDAP_INAPPROPRIATE_MATCHING; -- 2.39.5