[Fedora-directory-commits] ldapserver/ldap/servers/plugins/retrocl retrocl.c, 1.6, 1.7 retrocl_cn.c, 1.5, 1.6 retrocl_po.c, 1.7, 1.8 retrocl_trim.c, 1.8, 1.9

Richard Allen Megginson rmeggins at fedoraproject.org
Fri Dec 5 22:41:54 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/retrocl
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13701/ldapserver/ldap/servers/plugins/retrocl

Modified Files:
	retrocl.c retrocl_cn.c retrocl_po.c retrocl_trim.c 
Log Message:
Resolves: bug 454030
Bug Description: Need to address 64-bit compiler warnings - again
Reviewed by: nhosoi (Thanks!)
Fix Description: This patch cleans up most of the other remaining compiler warnings.  I compiled the directory server code with these flags on RHEL5 x86_64: -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic
I also enabled argument/format match checking for most of the commonly used varadic functions.  Most of the problems I found fell into these categories:
1) Too many or not enough arguments e.g. most everything that uses or did use LDAPDebug had extra 0,0 arguments.  If they had been switched to use slapi_log_error, I removed the extra arguments - for those places still using LDAPDebug, I introduced more macros to handle the number of arguments, since C macros cannot be varadic.
2) When using NSPR formatting functions, we have to use %llu or %lld for 64-bit values, even on 64-bit systems.  However, for regular system formatting functions, we have to use %ld or %lu.  I introduced two new macros NSPRIu64 and NSPRI64 to handle cases where we are passing explicit 64-bit values to NSPR formatting functions, so that we can use the regular PRIu64 and PRI64 macros for regular system formatting functions.  I also made sure we used NSPRI* only with NSPR functions, and used PRI* only with system functions.
3) use %lu for size_t and %ld for time_t
I did find a few "real" errors, places that the code was doing something definitely not right:
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/acl/aclinit.c_sec4
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/acl/acllas.c_sec17
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/http/http_impl.c_sec1
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/memberof/memberof.c_sec1
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/pam_passthru/pam_ptimpl.c_sec1
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/replication/cl5_api.c_sec5
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/replication/cl5_clcache.c_sec2
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/plugins/replication/replutil.c_sec1
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/slapd/libglobs.c_sec1
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/slapd/back-ldbm/dbverify.c_sec2
https://bugzilla.redhat.com/attachment.cgi?id=325774&action=diff#ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c_sec3
This is why it's important to use this compiler checking, and why it's important to fix compiler warnings, if for no other reason than the sheer noise from so many warnings can mask real errors.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no



Index: retrocl.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/retrocl/retrocl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- retrocl.c	10 Nov 2006 23:45:18 -0000	1.6
+++ retrocl.c	5 Dec 2008 22:41:52 -0000	1.7
@@ -221,8 +221,8 @@
     operation_free(&op,NULL);
 
     if (err != LDAP_SUCCESS || be == NULL || be == defbackend_get_backend()) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"Mapping tree select failed (%d) %s.\n",
-		  err,errbuf,0);
+        LDAPDebug2Args(LDAP_DEBUG_TRACE,"Mapping tree select failed (%d) %s.\n",
+		  err,errbuf);
 	
 	/* could not find the backend for cn=changelog, either because
 	 * it doesn't exist
@@ -307,7 +307,7 @@
       if (rc == 0) {
 	retrocl_init_trimming();
       } else {
-	LDAPDebug(LDAP_DEBUG_TRACE,"Couldnt find backend, not trimming retro changelog (%d).\n",rc,0,0);
+	LDAPDebug1Arg(LDAP_DEBUG_TRACE,"Couldnt find backend, not trimming retro changelog (%d).\n",rc);
       }
     }
    


Index: retrocl_cn.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/retrocl/retrocl_cn.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- retrocl_cn.c	10 Nov 2006 23:45:18 -0000	1.5
+++ retrocl_cn.c	5 Dec 2008 22:41:52 -0000	1.6
@@ -181,7 +181,7 @@
 
     retrocl_internal_cn = cr.cr_cnum;
     
-    slapi_log_error(SLAPI_LOG_PLUGIN,"retrocl","Got changenumbers %d and %d\n",
+    slapi_log_error(SLAPI_LOG_PLUGIN,"retrocl","Got changenumbers %lu and %lu\n",
 		    retrocl_first_cn,
 		    retrocl_internal_cn);
 
@@ -379,7 +379,7 @@
 
 
     retrocl_internal_cn = cr.cr_cnum;
-    slapi_log_error(SLAPI_LOG_PLUGIN,"retrocl","Refetched last changenumber =  %d \n",
+    slapi_log_error(SLAPI_LOG_PLUGIN,"retrocl","Refetched last changenumber =  %lu \n",
             retrocl_internal_cn);
 
     slapi_ch_free(( void **) &cr.cr_time );


Index: retrocl_po.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/retrocl/retrocl_po.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- retrocl_po.c	15 Oct 2008 06:29:59 -0000	1.7
+++ retrocl_po.c	5 Dec 2008 22:41:52 -0000	1.8
@@ -179,7 +179,7 @@
    
     PR_ASSERT( changenum > 0UL );
     slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME,
-	    "write_replog_db: write change record %d for dn: \"%s\"\n", 
+	    "write_replog_db: write change record %lu for dn: \"%s\"\n", 
 	    changenum, ( dn == NULL ) ? "NULL" : dn );
 
     /* Construct the dn of this change record */
@@ -271,7 +271,7 @@
 	if ( 0 != rc ) {
 	    slapi_log_error( SLAPI_LOG_FATAL, RETROCL_PLUGIN_NAME,
 			     "replog: an error occured while adding change "
-			     "number %d, dn = %s: %s. \n",
+			     "number %lu, dn = %s: %s. \n",
 			     changenum, edn, ldap_err2string( rc ));
 	    retrocl_release_changenumber();
 	} else {
@@ -484,27 +484,24 @@
     (void)slapi_pblock_get( pb, SLAPI_BACKEND, &be );
     
     if (slapi_be_logchanges(be) == 0) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"not applying change if not logging\n",
-		  0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if not logging\n");
 	return 0;
     }
     
     if (retrocl_be_changelog == NULL || be == retrocl_be_changelog) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"not applying change if no/cl be\n",0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no/cl be\n");
 	return 0;
     }
 
     slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
 
     if (rc != LDAP_SUCCESS) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"not applying change if op failed %d\n",rc,
-		  0,0);
+        LDAPDebug1Arg(LDAP_DEBUG_TRACE,"not applying change if op failed %d\n",rc);
 	return 0;
     }
 
     if (slapi_op_abandoned(pb)) {
-        LDAPDebug(LDAP_DEBUG_PLUGIN,"not applying change if op abandoned\n",
-		  0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_PLUGIN,"not applying change if op abandoned\n");
 	return 0;
     }
 
@@ -519,12 +516,12 @@
     slapi_pblock_get( pb, SLAPI_OPERATION, &op );
 
     if (op == NULL) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"not applying change if no op\n",0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no op\n");
         return 0;
     }
 
 	if (operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)){
-        LDAPDebug(LDAP_DEBUG_TRACE,"not applying change for nsTombstone entries\n",0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change for nsTombstone entries\n");
         return 0;
 	}
 	


Index: retrocl_trim.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/retrocl/retrocl_trim.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- retrocl_trim.c	18 Oct 2007 00:08:32 -0000	1.8
+++ retrocl_trim.c	5 Dec 2008 22:41:52 -0000	1.9
@@ -119,7 +119,7 @@
     
     if ( delrc != LDAP_SUCCESS ) {
 	slapi_log_error( SLAPI_LOG_FATAL, RETROCL_PLUGIN_NAME, "delete_changerecord: could not delete "
-		"change record %d\n", cnum );
+		"change record %lu\n", cnum );
     } else {
 	slapi_log_error( SLAPI_LOG_PLUGIN, RETROCL_PLUGIN_NAME,
 		"delete_changerecord: deleted changelog entry \"%s\"\n", dnbuf);
@@ -312,7 +312,7 @@
 	    }
 	}
     } else {
-       LDAPDebug(LDAP_DEBUG_PLUGIN, "not yet time to trim: %d < (%d+%d)\n",
+       LDAPDebug(LDAP_DEBUG_PLUGIN, "not yet time to trim: %ld < (%d+%d)\n",
 		 now,lt,(CHANGELOGDB_TRIM_INTERVAL/1000));
     }
     PR_Lock( ts.ts_s_trim_mutex );
@@ -366,7 +366,7 @@
     int			ldrc;
 
     if (retrocl_be_changelog == NULL) {
-        LDAPDebug(LDAP_DEBUG_TRACE,"not housekeeping if no cl be\n",0,0,0);
+        LDAPDebug0Args(LDAP_DEBUG_TRACE,"not housekeeping if no cl be\n");
 	return;
     }
 
@@ -391,7 +391,7 @@
 		 */
 		first_time = retrocl_getchangetime( SLAPI_SEQ_FIRST, &ldrc );
 		LDAPDebug(LDAP_DEBUG_PLUGIN,
-			  "cltrim: ldrc=%d, first_time=%d, cur_time=%d\n",
+			  "cltrim: ldrc=%d, first_time=%ld, cur_time=%ld\n",
 			  ldrc,first_time,cur_time);
 		if ( LDAP_SUCCESS == ldrc && first_time > (time_t) 0L &&
 		     first_time + ts.ts_c_max_age < cur_time ) {
@@ -399,7 +399,7 @@
 		}
 	}
 	if ( must_trim ) {
-	    LDAPDebug(LDAP_DEBUG_TRACE,"changelog about to create thread\n",0,0,0);
+	    LDAPDebug0Args(LDAP_DEBUG_TRACE,"changelog about to create thread\n");
 	    /* Start a thread to trim the changelog */
 	    ts.ts_s_trimming = 1;
 	    if ( PR_CreateThread( PR_USER_THREAD,
@@ -409,8 +409,8 @@
 		slapi_log_error( SLAPI_LOG_FATAL, RETROCL_PLUGIN_NAME, "unable to create changelog trimming thread\n" );
 	    }
 	} else {
-	    LDAPDebug(LDAP_DEBUG_PLUGIN,
-		      "changelog does not need to be trimmed\n",0,0,0);
+	    LDAPDebug0Args(LDAP_DEBUG_PLUGIN,
+		      "changelog does not need to be trimmed\n");
 	}
     }
     PR_Unlock( ts.ts_s_trim_mutex );
@@ -491,7 +491,7 @@
     cl_maxage = retrocl_get_config_str(CONFIG_CHANGELOG_MAXAGE_ATTRIBUTE);
     
     if (cl_maxage == NULL) {
-      LDAPDebug(LDAP_DEBUG_TRACE,"No maxage, not trimming retro changelog.\n",0,0,0);
+      LDAPDebug0Args(LDAP_DEBUG_TRACE,"No maxage, not trimming retro changelog.\n");
       return;
     }
     ageval = age_str2time (cl_maxage);




More information about the Fedora-directory-commits mailing list