Răsfoiți Sursa

Bug 677440 - clean up compiler warnings in 389-ds-base 1.2.8

https://bugzilla.redhat.com/show_bug.cgi?id=677440
Resolves: bug 677440
Description: clean up compiler warnings in 389-ds-base 1.2.8
* added is_slapd_running to shared header file
* added parentheses around assignment used as truth value
* added printf format string for ber_tag_t and ber_len_t
* fixed type usage in config_get_anon_access_switch
* fixed variable declaration in acl_check_for_target_macro
* use %lu for size_t in scanf and printf
* fixed usage of matcheddnp in cb_sasl_bind_once_s
Reviewed by: nkinder (Thanks!)
Rich Megginson 14 ani în urmă
părinte
comite
79a3fae13f

+ 1 - 1
ldap/servers/plugins/acl/aclparse.c

@@ -1641,7 +1641,7 @@ acl_check_for_target_macro( aci_t *aci_item, char *value)
 	str = strstr(value, ACL_TARGET_MACRO_DN_KEY /* ($dn) */);	
 	
 	if (str != NULL) {
-		char *p0 = NULL, p1 = NULL;
+		char *p0 = NULL, *p1 = NULL;
 		/* Syntax check: 
 		 * error return if ($dn) is in '[' and ']', e.g., "[($dn)]" */
 		p0 = strchr(value, '[');

+ 3 - 2
ldap/servers/plugins/chainingdb/cb_bind.c

@@ -181,10 +181,11 @@ cb_sasl_bind_once_s( cb_conn_pool *pool, char *dn, int method, char * mechanism,
 	if ( LDAP_SUCCESS != rc )  {
 		static int warned_bind_once = 0;
 		if (!warned_bind_once) {
+			int hasmatched = (matcheddnp && *matcheddnp && (**matcheddnp != '\0'));
 			slapi_log_error(SLAPI_LOG_FATAL, CB_PLUGIN_SUBSYSTEM,
 			                "cb_sasl_bind_once_s failed (%s%s%s)\n",
-			                matcheddnp?matcheddnp:"", 
-							(matcheddnp&&(*matcheddnp!='\0'))?": ":"",
+			                hasmatched ? *matcheddnp : "", 
+			                hasmatched ? ": " : "",
 			                ldap_err2string(rc));
 			warned_bind_once = 1;
 		}

+ 0 - 1
ldap/servers/plugins/chainingdb/cb_conn_stateless.c

@@ -171,7 +171,6 @@ cb_get_connection(cb_conn_pool * pool,
 	int 				secure;
 	char 				*mech = NULL;;
 	static	char		*error1="Can't contact remote server : %s";
-	static	char		*error2="Can't bind to remote server : %s";
 	int					isMultiThread = ENABLE_MULTITHREAD_PER_CONN ; /* by default, we enable multiple operations per connection */
 	
 	/*

+ 0 - 1
ldap/servers/plugins/mep/mep.c

@@ -2371,7 +2371,6 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
                     slapi_mods_free(&smods);
                 }
 
-              bail:
                 slapi_sdn_free(&managed_sdn);
                 slapi_entry_free(new_managed_entry);
             }

+ 1 - 1
ldap/servers/plugins/replication/cl5_api.c

@@ -1970,7 +1970,7 @@ static int _cl5AppInit (PRBool *didRecovery)
 	{
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, 
 				"_cl5AppInit: failed to fetch backend dbenv (%p) and/or "
-				"index page size (%u)\n", dbEnv, pagesize);
+				"index page size (%lu)\n", dbEnv, pagesize);
 		return CL5_DB_ERROR;
 	}
 }

+ 0 - 1
ldap/servers/plugins/replication/repl5_replica.c

@@ -2390,7 +2390,6 @@ replica_write_ruv (Replica *r)
 int
 replica_ruv_smods_for_op( Slapi_PBlock *pb, char **uniqueid, Slapi_Mods **smods )
 {
-    int rc = 0;
     Object *replica_obj;
     Object *ruv_obj;
     Replica *replica;

+ 1 - 1
ldap/servers/slapd/attrsyntax.c

@@ -826,7 +826,7 @@ slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr)
 	int dn_syntax = 0; /* not DN, by default */
 
 	if (attr && attr->a_plugin) { /* If not set, there is no way to get the info */
-		if (syntaxoid = attr_get_syntax_oid(attr)) {
+		if ((syntaxoid = attr_get_syntax_oid(attr))) {
 			dn_syntax = ((0 == strcmp(syntaxoid, NAMEANDOPTIONALUID_SYNTAX_OID))
 						 || (0 == strcmp(syntaxoid, DN_SYNTAX_OID)));
 		}

+ 2 - 2
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -924,7 +924,7 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_
                 if (feof(f))
                     break;
                 if (strncmp(s, "VmSize:", 7) == 0) {
-                    sscanf(s+7, "%u", procpages);
+                    sscanf(s+7, "%lu", procpages);
                     break;
                 }
             }
@@ -4213,7 +4213,7 @@ static int commit_good_database(dblayer_private *priv)
             filename, PR_GetError(), slapd_pr_strerror(PR_GetError()) );
         return -1;
     } 
-    PR_snprintf(line,sizeof(line),"cachesize:%u\nncache:%d\nversion:%d\n",
+    PR_snprintf(line,sizeof(line),"cachesize:%lu\nncache:%d\nversion:%d\n",
             priv->dblayer_cachesize, priv->dblayer_ncache, DB_VERSION_MAJOR);
     num_bytes = strlen(line);
     return_value = slapi_write_buffer(prfd, line, num_bytes);

+ 8 - 8
ldap/servers/slapd/back-ldbm/import-threads.c

@@ -722,8 +722,8 @@ import_producer(void *param)
                     "ending line %d of file \"%s\"",
                     escape_string(slapi_entry_get_dn(e), ebuf),
                     curr_lineno, curr_filename);
-            import_log_notice(job, "REASON: entry too large (%u bytes) for "
-                    "the buffer size (%u bytes)", newesize, job->fifo.bsize);
+            import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the buffer size (%lu bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -853,8 +853,8 @@ index_set_entry_to_fifo(ImportWorkerInfo *info, Slapi_Entry *e,
         char ebuf[BUFSIZ];
         import_log_notice(job, "WARNING: skipping entry \"%s\"",
                     escape_string(slapi_entry_get_dn(e), ebuf));
-        import_log_notice(job, "REASON: entry too large (%u bytes) for "
-                    "the buffer size (%u bytes)", newesize, job->fifo.bsize);
+        import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the buffer size (%lu bytes)", newesize, job->fifo.bsize);
         backentry_free(&ep);
         job->skipped++;
         rc = 0; /* go to the next loop */
@@ -1728,8 +1728,8 @@ upgradedn_producer(void *param)
             char ebuf[BUFSIZ];
             import_log_notice(job, "WARNING: skipping entry \"%s\"",
                     escape_string(slapi_entry_get_dn(e), ebuf));
-            import_log_notice(job, "REASON: entry too large (%u bytes) for "
-                    "the buffer size (%u bytes)", newesize, job->fifo.bsize);
+            import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the buffer size (%lu bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -2871,8 +2871,8 @@ static int bulk_import_queue(ImportJob *job, Slapi_Entry *entry)
         char ebuf[BUFSIZ];
         import_log_notice(job, "WARNING: skipping entry \"%s\"",
                     escape_string(slapi_entry_get_dn(ep->ep_entry), ebuf));
-        import_log_notice(job, "REASON: entry too large (%u bytes) for "
-                    "the import buffer size (%u bytes).   Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
+        import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the import buffer size (%lu bytes).   Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
         backentry_clear_entry(ep);      /* entry is released in the frontend on failure*/
         backentry_free( &ep );          /* release the backend wrapper, here */
         PR_Unlock(job->wire_lock);

+ 2 - 2
ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c

@@ -1509,11 +1509,11 @@ _back_crypt_crypto_op(attrcrypt_private *priv,
     }
     if (encrypt) {
         slapi_log_error(SLAPI_LOG_BACKLDBM, ATTRCRYPT,
-                        "_back_crypt_crypto_op encrypt '%s' (%d)\n", 
+                        "_back_crypt_crypto_op encrypt '%s' (%lu)\n", 
                         in_data, in_size);
     } else {
         slapi_log_error(SLAPI_LOG_BACKLDBM, ATTRCRYPT,
-                        "_back_crypt_crypto_op decrypt (%d)\n", in_size);
+                        "_back_crypt_crypto_op decrypt (%lu)\n", in_size);
     }
     /* Allocate the output buffer */
     output_buffer_length = in_size + BACK_CRYPT_OUTBUFF_EXTLEN;

+ 3 - 3
ldap/servers/slapd/connection.c

@@ -2691,13 +2691,13 @@ log_ber_too_big_error(const Connection *conn, ber_len_t ber_len,
 	if (0 == ber_len) {
 		slapi_log_error( SLAPI_LOG_FATAL, "connection",
 			"conn=%" NSPRIu64 " fd=%d Incoming BER Element was too long, max allowable"
-			" is %u bytes. Change the nsslapd-maxbersize attribute in"
+			" is %" BERLEN_T " bytes. Change the nsslapd-maxbersize attribute in"
 			" cn=config to increase.\n",
 			conn->c_connid, conn->c_sd, maxbersize );
 	} else {
 		slapi_log_error( SLAPI_LOG_FATAL, "connection",
-			"conn=%" NSPRIu64 " fd=%d Incoming BER Element was %u bytes, max allowable"
-			" is %u bytes. Change the nsslapd-maxbersize attribute in"
+			"conn=%" NSPRIu64 " fd=%d Incoming BER Element was %" BERLEN_T " bytes, max allowable"
+			" is %" BERLEN_T " bytes. Change the nsslapd-maxbersize attribute in"
 			" cn=config to increase.\n",
 			conn->c_connid, conn->c_sd, ber_len, maxbersize );
 	}

+ 1 - 1
ldap/servers/slapd/libglobs.c

@@ -4617,7 +4617,7 @@ config_get_require_secure_binds(void)
 int
 config_get_anon_access_switch(void)
 {
-	char *retVal = NULL;
+	int retVal = 0;
 	slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 	CFG_LOCK_READ(slapdFrontendConfig);
         retVal = slapdFrontendConfig->allow_anon_access;

+ 6 - 6
ldap/servers/slapd/result.c

@@ -1690,7 +1690,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%" NSPRIu64 " op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
 								  ", SASL bind in progress\n",
 								  op->o_connid, 
 								  op->o_opid,
@@ -1702,7 +1702,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
 								  ", SASL bind in progress\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,
@@ -1722,7 +1722,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%" NSPRIu64 " op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
 								  " dn=\"%s\"\n",
 								  op->o_connid, 
 								  op->o_opid,
@@ -1734,7 +1734,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s"
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s"
 								  " dn=\"%s\"\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,	
@@ -1748,7 +1748,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%" NSPRIu64 " op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s\n",
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s\n",
 								  op->o_connid, 
 								  op->o_opid,
 								  err, tag, nentries, 
@@ -1759,7 +1759,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%u nentries=%d etime=%s%s%s\n",
+								  " tag=%" BERTAG_T " nentries=%d etime=%s%s%s\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,
 								  err, tag, nentries, 

+ 10 - 0
ldap/servers/slapd/slapi-plugin.h

@@ -96,6 +96,16 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
 #define NSPRIu64	"llu"
 #define NSPRI64	"ll"
 
+/* OpenLDAP uses unsigned long for ber_tag_t and ber_len_t but mozldap uses unsigned int */
+/* use this macro for printf statements for ber_tag_t and ber_len_t */
+#if defined(USE_OPENLDAP)
+#define BERTAG_T "lu"
+#define BERLEN_T "lu"
+#else
+#define BERTAG_T "u"
+#define BERLEN_T "u"
+#endif
+
 /*
  * The slapi_attr_get_flags() routine returns a bitmap that contains one or
  * more of these values.

+ 7 - 0
ldap/servers/slapd/slapi-private.h

@@ -1228,6 +1228,13 @@ void    DS_Sleep(PRIntervalTime ticks);
 /* plugin.c */
 int plugin_enabled(const char *plugin_name, void *identity);
 
+/* protect_db.c */
+/* is_slapd_running()
+ * returns 1 if slapd is running, 0 if not, -1 on error
+ */
+int is_slapd_running();
+
+
 #ifdef __cplusplus
 }
 #endif