[Fedora-directory-commits] ldapserver/ldap/servers/slapd agtmmap.c, 1.10, 1.11 auth.c, 1.10, 1.11 bind.c, 1.13, 1.14 config.c, 1.11, 1.12 configdse.c, 1.8, 1.9 conntable.c, 1.9, 1.10 detach.c, 1.7, 1.8 dse.c, 1.9, 1.10 filter.c, 1.9, 1.10 libglobs.c, 1.24, 1.25 log.c, 1.22, 1.23 log.h, 1.7, 1.8 main.c, 1.24, 1.25 mapping_tree.c, 1.14, 1.15 pblock.c, 1.16, 1.17 saslbind.c, 1.26, 1.27 snmp_collator.c, 1.13, 1.14 statechange.h, 1.5, 1.6 task.c, 1.15, 1.16 uuid.c, 1.11, 1.12

Richard Allen Megginson rmeggins at fedoraproject.org
Wed Oct 8 17:29:05 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd

Modified Files:
	agtmmap.c auth.c bind.c config.c configdse.c conntable.c 
	detach.c dse.c filter.c libglobs.c log.c log.h main.c 
	mapping_tree.c pblock.c saslbind.c snmp_collator.c 
	statechange.h task.c uuid.c 
Log Message:
Bug Description: Need to address 64-bit compiler warnings - part 1
Reviewed by: nhosoi (Thanks!)
Fix Description: The intptr_t and uintptr_t are types which are defined as integer types that are the same size as the pointer (void *) type.  On the platforms we currently support, this is the same as long and unsigned long, respectively (ILP32 and LP64).  However, intptr_t and uintptr_t are more portable.  These can be used to assign a value passed as a void * to get an integer value, then "cast down" to an int or PRBool, and vice versa.  This seems to be a common idiom in other applications where values must be passed as void *.
For the printf/scanf formats, there is a standard header called inttypes.h which defines formats to use for various 64 bit quantities, so that you don't need to figure out if you have to use %lld or %ld for a 64-bit value - you just use PRId64 which is set to the correct value.  I also assumed that size_t is defined as the same size as a pointer so I used the PRIuPTR format macro for size_t.
I removed many unused variables and some unused functions.
I put parentheses around assignments in conditional expressions to tell the compiler not to complain about them.
I cleaned up some #defines that were defined more than once.
I commented out some unused goto labels.
Some of our header files shared among several source files define static variables.  I made it so that those variables are not defined unless a macro is set in the source file.  This avoids a lot of unused variable warnings.
I added some return values to functions that were declared as returning a value but did not return a value.  In all of these cases no one was checking the return value anyway.
I put explicit parentheses around cases like this: expr || expr && expr - the && has greater precedence than the ||.  The compiler complains because it wants you to make sure you mean expr || (expr && expr), not (expr || expr) && expr.
I cleaned up several places where the compiler was complaining about possible use of uninitialized variables.  There are still a lot of these cases remaining.
There are a lot of warnings like this:
lib/ldaputil/certmap.c:1279: warning: dereferencing type-punned pointer will break strict-aliasing rules
These are due to our use of void ** to pass in addresses of addresses of structures.  Many of these are calls to slapi_ch_free, but many are not - they are cases where we do not know what the type is going to be and may have to cast and modify the structure or pointer.  I started replacing the calls to slapi_ch_free with slapi_ch_free_string, but there are many many more that need to be fixed.
The dblayer code also contains a fix for https://bugzilla.redhat.com/show_bug.cgi?id=463991 - instead of checking for dbenv->foo_handle to see if a db "feature" is enabled, instead check the flags passed to open the dbenv.  This works for bdb 4.2 through bdb 4.7 and probably other releases as well.
Platforms tested: RHEL5 x86_64, Fedora 8 i386
Flag Day: no
Doc impact: no



Index: agtmmap.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/agtmmap.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- agtmmap.c	10 Nov 2006 23:45:40 -0000	1.10
+++ agtmmap.c	8 Oct 2008 17:29:03 -0000	1.11
@@ -195,7 +195,7 @@
 		   {
 			   /* Without this we will get segv when we try to read/write later */
 			   buf = calloc (1, sz);
-			   write (fd, buf, sz);
+			   (void)write (fd, buf, sz);
 			   free (buf);
 		   }
 


Index: auth.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/auth.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- auth.c	27 Aug 2008 21:56:07 -0000	1.10
+++ auth.c	8 Oct 2008 17:29:03 -0000	1.11
@@ -449,7 +449,7 @@
     if ( conn->c_flags & CONN_FLAG_START_TLS ) {
         if ( cipherInfo.symKeyBits == 0 ) {
 	        start_tls_graceful_closure( conn, NULL, 1 );
-			slapi_ch_free((void **)&cipher);
+			slapi_ch_free_string(&cipher);
 	        return ;
 	}
     }
@@ -457,7 +457,7 @@
     if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF ) {
 		slapi_log_access (LDAP_DEBUG_STATS, "conn=%d SSL %i-bit %s\n",
 		   		conn->c_connid, keySize, cipher ? cipher : "NULL" );
-		slapi_ch_free((void **)&cipher);
+		slapi_ch_free_string(&cipher);
 		return;
     } 
     if (clientCert == NULL) {
@@ -499,7 +499,7 @@
 	        LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %i (%s)%s\n",
 			   err, extraErrorMsg, chain ? "" : " NULL");
 	    }
-		slapi_ch_free((void**)&basedn);
+		slapi_ch_free_string(&basedn);
 	    slapu_msgfree (internal_ld, chain);
 	}
 	if (subject) free (subject);
@@ -522,6 +522,6 @@
 	bind_credentials_set( conn, SLAPD_AUTH_SSL, clientDN,
 			SLAPD_AUTH_SSL, clientDN, clientCert , NULL);
 
-    slapi_ch_free((void **)&cipher);
+    slapi_ch_free_string(&cipher);
     /* clientDN and clientCert will be freed later */
 }


Index: bind.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/bind.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- bind.c	27 Aug 2008 21:05:17 -0000	1.13
+++ bind.c	8 Oct 2008 17:29:03 -0000	1.14
@@ -103,7 +103,7 @@
 		rv = slapi_pw_find_sv( rdnpwvals, cred ) == 0;
 		value_done(&rdnpwbv);
 	}
-	slapi_ch_free( (void **) &rootpw );
+	slapi_ch_free_string( &rootpw );
 	return rv;
 }
 
@@ -787,6 +787,6 @@
 	}
 
 	if ( NULL != dnbuf_dynamic ) {
-		slapi_ch_free( (void **)&dnbuf_dynamic );
+		slapi_ch_free_string( &dnbuf_dynamic );
 	}
 }


Index: config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/config.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- config.c	14 May 2008 18:39:31 -0000	1.11
+++ config.c	8 Oct 2008 17:29:03 -0000	1.12
@@ -566,11 +566,11 @@
 			}
 		}
 
-		slapi_ch_free((void **)&buf);
+		slapi_ch_free_string(&buf);
 	}
 
 bail:
-	slapi_ch_free((void **)&buf);
+	slapi_ch_free_string(&buf);
 	return rc;
 }
 


Index: configdse.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/configdse.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- configdse.c	17 Sep 2007 22:48:10 -0000	1.8
+++ configdse.c	8 Oct 2008 17:29:03 -0000	1.9
@@ -102,7 +102,7 @@
 		retval = (ptype && !strcasecmp(ptype, "pwdstoragescheme"));
 	if (!retval)
 		retval = (ptype && !strcasecmp(ptype, "reverpwdstoragescheme"));
-	slapi_ch_free((void**)&ptype);
+	slapi_ch_free_string(&ptype);
 	return retval;
 }
 
@@ -178,7 +178,7 @@
 		be = slapi_get_next_backend (cookie);
     }
 
-	slapi_ch_free ((void **)&cookie);
+	slapi_ch_free_string (&cookie);
 
 	/* show be_type */
 	attrlist_delete( &e->e_attrs, "nsslapd-betype");
@@ -195,7 +195,7 @@
 		be = slapi_get_next_backend(cookie);
 	}
 
-	slapi_ch_free ( (void **) &cookie);
+	slapi_ch_free_string (&cookie);
 
     /* show private suffixes */
     attrlist_delete ( &e->e_attrs, "nsslapd-privatenamespaces");
@@ -222,7 +222,7 @@
 		be = slapi_get_next_backend(cookie);    	
     }
 
-	slapi_ch_free ((void **) &cookie);
+	slapi_ch_free_string (&cookie);
 
 	/* show syntax plugins */
 	attrlist_delete ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE );
@@ -432,7 +432,7 @@
 	/* if the password has been set, it will be hashed */
 	if ((pwd = config_get_rootpw()) != NULL) {
 		slapi_entry_attr_set_charptr(e, CONFIG_ROOTPW_ATTRIBUTE, pwd);
-		slapi_ch_free((void**)&pwd);
+		slapi_ch_free_string(&pwd);
 	}
 
 	*returncode= rc;


Index: conntable.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/conntable.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- conntable.c	18 Oct 2007 00:08:34 -0000	1.9
+++ conntable.c	8 Oct 2008 17:29:03 -0000	1.10
@@ -438,7 +438,7 @@
 			val.bv_len = strlen( bufptr );
 			attrlist_merge( &e->e_attrs, "connection", vals );
 			if (newbuf) {
-				slapi_ch_free((void **) &newbuf);
+				slapi_ch_free_string(&newbuf);
 			}
 		}
 		PR_Unlock( ct->c[i].c_mutex );


Index: detach.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/detach.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- detach.c	3 Apr 2008 21:07:55 -0000	1.7
+++ detach.c	8 Oct 2008 17:29:03 -0000	1.8
@@ -127,7 +127,7 @@
 				}
 				(void) chdir( errorlog );
 				config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1);
-				slapi_ch_free((void**)&errorlog);
+				slapi_ch_free_string(&errorlog);
 			}
 		} else {
 			/* calling config_set_workingdir to check for validity of directory, don't apply */
@@ -135,7 +135,7 @@
 				exit(1);
 			}
 			(void) chdir( workingdir );
-			slapi_ch_free((void**)&workingdir);
+			slapi_ch_free_string(&workingdir);
 		}
 
 		if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {


Index: dse.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/dse.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- dse.c	4 Jun 2008 22:22:55 -0000	1.9
+++ dse.c	8 Oct 2008 17:29:03 -0000	1.10
@@ -72,6 +72,13 @@
 #include <pwd.h>
 #endif  /* _WIN32 */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 /* #define SLAPI_DSE_DEBUG */ 	/* define this to force trace log	*/
 								/* messages to always be logged		*/
 
@@ -463,6 +470,8 @@
     slapi_ch_free((void **)&pdse);
     LDAPDebug( SLAPI_DSE_TRACELEVEL, "Removed [%d] entries from the dse tree.\n",
                  nentries,0,0 );
+
+    return 0; /* no one checks this return value */
 }
 
 /*
@@ -603,7 +612,7 @@
         struct berval val;
         vals[0] = &val;
         vals[1] = NULL;
-        sprintf(value_buffer,"%lu",current_sub_count);
+        sprintf(value_buffer,"%" PRIuPTR,current_sub_count);
         val.bv_val = value_buffer;
         val.bv_len = strlen (val.bv_val);
         switch(mod_op)


Index: filter.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/filter.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- filter.c	10 Nov 2006 23:45:40 -0000	1.9
+++ filter.c	8 Oct 2008 17:29:03 -0000	1.10
@@ -1280,7 +1280,7 @@
 			if(1 < *bufsize)
 			{
 				sprintf( buf, ")" );
-				*bufsize--;
+				(*bufsize)--;
 			}
 		}
 		break;
@@ -1313,7 +1313,7 @@
 			if(1 < *bufsize)
 			{
 				sprintf( buf, ")" );
-				*bufsize--;
+				(*bufsize)--;
 			}
 		}
 		break;


Index: libglobs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/libglobs.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- libglobs.c	27 Aug 2008 21:05:25 -0000	1.24
+++ libglobs.c	8 Oct 2008 17:29:03 -0000	1.25
@@ -5066,6 +5066,8 @@
 {
     struct berval **values = 0;
     char *sval = 0;
+    int ival = 0;
+    uintptr_t pval;
 
     /* for null values, just set the attr value to the empty
        string */
@@ -5125,7 +5127,9 @@
 
     case CONFIG_CONSTANT_INT:
         PR_ASSERT(value); /* should be a constant value */
-        slapi_entry_attr_set_int(e, cgas->attr_name, (int)value);
+        pval = (uintptr_t)value;
+        ival = (int)pval;
+        slapi_entry_attr_set_int(e, cgas->attr_name, ival);
         break;
 
     case CONFIG_SPECIAL_SSLCLIENTAUTH:


Index: log.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- log.c	3 Apr 2008 17:18:11 -0000	1.22
+++ log.c	8 Oct 2008 17:29:03 -0000	1.23
@@ -2216,12 +2216,12 @@
 {
 	time_t	curr_time;
 	time_t	log_createtime= 0;
-	time_t	syncclock;
+	time_t	syncclock = 0;
 	int	type = LOG_CONTINUE;
 	int	f_size = 0;
 	int	maxlogsize, nlogs;
 	int	rotationtime_secs = -1;
-	int	sync_enabled, timeunit;
+	int	sync_enabled = 0, timeunit = 0;
 
 	if (fp == NULL) {
 		return LOG_ROTATE;


Index: log.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- log.h	10 Nov 2006 23:45:40 -0000	1.7
+++ log.h	8 Oct 2008 17:29:03 -0000	1.8
@@ -49,9 +49,13 @@
  *************************************************************************/
 #include <stdio.h>
 #ifdef LINUX
+#ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE /* glibc2 needs this */
+#endif
+#ifndef __USE_XOPEN
 #define __USE_XOPEN
 #endif
+#endif
 #include <time.h>
 #include <stdarg.h>
 #include <sys/types.h>


Index: main.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/main.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- main.c	3 Apr 2008 21:07:55 -0000	1.24
+++ main.c	8 Oct 2008 17:29:03 -0000	1.25
@@ -261,7 +261,6 @@
 fix_ownership() 
 {
 	struct passwd* pw=NULL;
-	char dirname[MAXPATHLEN + 1];
 
 	slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
@@ -630,7 +629,6 @@
 	slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 	daemon_ports_t ports_info = {0};
    	Slapi_Backend *be = NULL;
-	int init_ssl;
 #ifndef __LP64__ 
 #if defined(__hpux) && !defined(__ia64)
 	/* for static constructors */
@@ -2598,7 +2596,6 @@
     int return_value = 0;
     Slapi_PBlock pb;
     struct slapdplugin *backend_plugin;
-    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
     /* this should be the first time to be called!  if the init order
      * is ever changed, these lines should be changed (or erased)!


Index: mapping_tree.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/mapping_tree.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- mapping_tree.c	12 Jun 2008 15:23:44 -0000	1.14
+++ mapping_tree.c	8 Oct 2008 17:29:03 -0000	1.15
@@ -1998,7 +1998,7 @@
      *  will be transferred to the internal DSE backend 
      */
     if( sdn_is_nulldn(target_sdn) &&
-        ((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE)  ||
+        (((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE)) ||
          (op_type != SLAPI_OPERATION_SEARCH)) ) {
 
         mtn_unlock();


Index: pblock.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/pblock.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- pblock.c	5 Aug 2008 22:18:37 -0000	1.16
+++ pblock.c	8 Oct 2008 17:29:03 -0000	1.17
@@ -2873,7 +2873,7 @@
 		
 	case SLAPI_LDIF2DB_ENCRYPT:
 	case SLAPI_DB2LDIF_DECRYPT:
-		pblock->pb_ldif_encrypt = (int)value;
+		pblock->pb_ldif_encrypt = *((int *)value);
 		break;
 
 	default:


Index: saslbind.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/saslbind.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- saslbind.c	27 Aug 2008 21:05:35 -0000	1.26
+++ saslbind.c	8 Oct 2008 17:29:03 -0000	1.27
@@ -297,7 +297,6 @@
     int attrsonly = 0, scope = LDAP_SCOPE_SUBTREE;
     LDAPControl **ctrls = NULL;
     Slapi_Entry *entry = NULL;
-    Slapi_DN *sdn;
     char **attrs = NULL;
     int regexmatch = 0;
     char *base = NULL;


Index: snmp_collator.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/snmp_collator.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- snmp_collator.c	18 Oct 2007 14:05:24 -0000	1.13
+++ snmp_collator.c	8 Oct 2008 17:29:03 -0000	1.14
@@ -399,7 +399,6 @@
 
   int err;
   char *statspath = config_get_rundir();
-  char *lp = NULL;
   char *instdir = config_get_configdir();
   char *instname = NULL;
 


Index: statechange.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/statechange.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- statechange.h	10 Nov 2006 23:45:40 -0000	1.5
+++ statechange.h	8 Oct 2008 17:29:03 -0000	1.6
@@ -78,7 +78,9 @@
 #define STATECHANGE_VATTR_ENTRY_INVALIDATE 2
 
 /* Vattr api caller data to be passed to statechange_register() */
+#ifdef DEFINE_STATECHANGE_STATICS
 static int vattr_global_invalidate = STATECHANGE_VATTR_GLOBAL_INVALIDATE;
-static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE;
+/* static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE; */
+#endif /* DEFINE_STATECHANGE_STATICS */
 
 #endif /*_STATE_NOTIFY_H_*/


Index: task.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/task.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- task.c	3 Apr 2008 16:52:46 -0000	1.15
+++ task.c	8 Oct 2008 17:29:03 -0000	1.16
@@ -193,6 +193,8 @@
     if (task) {
         return task->task_state;
     }
+
+    return 0; /* return value not currently used */
 }
 
 /* this changes the 'nsTaskStatus' value, which is transient (anything logged
@@ -341,6 +343,8 @@
     if (task) {
         return task->task_private;
     }
+
+    return NULL; /* return value not currently used */
 }
 
 /*
@@ -371,6 +375,8 @@
     if (task) {
         return task->task_refcount;
     }
+
+    return 0; /* return value not currently used */
 }
 
 /* name is, for example, "import" */


Index: uuid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/uuid.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- uuid.c	18 Oct 2007 00:08:34 -0000	1.11
+++ uuid.c	8 Oct 2008 17:29:03 -0000	1.12
@@ -361,8 +361,8 @@
 /* uuid_create -- multithreaded generation */
 static int uuid_create_mt(guid_t *uuid) 
 {
-    uuid_time_t timestamp;
-	unsigned16 clock_seq;
+    uuid_time_t timestamp = 0;
+	unsigned16 clock_seq = 0;
 
 	/* just bumps time sequence number. the actual
        time calls are made by a uuid_update_state */




More information about the Fedora-directory-commits mailing list