Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd/tools/rsearch
Modified Files:
infadd.c rsearch.c searchthread.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: infadd.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/infadd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- infadd.c 18 Oct 2007 23:49:32 -0000 1.6
+++ infadd.c 8 Oct 2008 17:29:04 -0000 1.7
@@ -344,11 +344,12 @@
}
if (lmtCount && ntotal >= lmtCount) {
if (!quiet) {
+ tmpv = (double)ntotal*1000.0/(counter*sampleInterval);
fprintf(stdout,
"Total added records: %d, Average rate: %7.2f/thrd, "
"%6.2f/sec = %6.4fmsec/op\n",
ntotal, (double)ntotal/(double)numThreads,
- (tmpv = (double)ntotal*1000.0/(counter*sampleInterval)),
+ tmpv,
(double)1000.0/tmpv);
}
exit(1);
Index: rsearch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/rsearch.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- rsearch.c 1 Aug 2007 17:51:10 -0000 1.4
+++ rsearch.c 8 Oct 2008 17:29:04 -0000 1.5
@@ -501,12 +501,12 @@
exit(0);
}
if (timeLimit && (lifeTime >= timeLimit)) {
- double tmpv;
+ double tmpv = (val + sumVal)/counter;
if (verbose)
printf("%d sec >= %d\n", lifeTime, timeLimit);
printf("Final Average rate: "
"%6.2f/sec = %6.4fmsec/op, total:%6u\n",
- (tmpv = (val + sumVal)/counter),
+ tmpv,
(double)1000.0/tmpv,
total);
exit(0);
Index: searchthread.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/searchthread.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- searchthread.c 1 Aug 2007 17:51:10 -0000 1.5
+++ searchthread.c 8 Oct 2008 17:29:04 -0000 1.6
@@ -501,7 +501,7 @@
{
SearchThread *st = (SearchThread *)v;
PRIntervalTime timer;
- int notBound = 1, res, searches = 0;
+ int notBound = 1, res = LDAP_SUCCESS, searches = 0;
PRUint32 span;
st->alive = 1;
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd/tools/ldclt
Modified Files:
ldapfct.c scalab01.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: ldapfct.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/ldapfct.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ldapfct.c 18 Oct 2007 00:08:35 -0000 1.7
+++ ldapfct.c 8 Oct 2008 17:29:04 -0000 1.8
@@ -671,9 +671,9 @@
*/
tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
+ printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- (unsigned int)tttctx->ldapCtx);
+ tttctx->ldapCtx);
if (tttctx->ldapCtx == NULL)
{
printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -689,14 +689,14 @@
ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
if (mctx.mode & VERY_VERBOSE)
printf
- ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+ ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
mctx.cltcertname);
if (ret < 0)
{
printf
- ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+ ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
mctx.cltcertname);
ldap_perror(tttctx->ldapCtx, "ldapssl_enable_clientauth");
fflush (stdout);
@@ -709,9 +709,9 @@
*/
tttctx->ldapCtx = ldap_init (mctx.hostname, mctx.port);
if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%08x\n",
+ printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%p\n",
mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- (unsigned int)tttctx->ldapCtx);
+ tttctx->ldapCtx);
if (tttctx->ldapCtx == NULL)
{
printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n",
@@ -805,7 +805,6 @@
} else if ((mctx.mod2 & M2_SASLAUTH) && ((!(tttctx->binded)) ||
(mctx.mode & BIND_EACH_OPER))) {
void *defaults;
- LDAPControl **rctrls = NULL;
char *my_saslauthid = NULL;
if ( mctx.sasl_mech == NULL) {
@@ -1836,9 +1835,9 @@
*/
tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
+ printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
- (unsigned int)tttctx->ldapCtx);
+ tttctx->ldapCtx);
if (tttctx->ldapCtx == NULL)
{
printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -1854,14 +1853,14 @@
ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
if (mctx.mode & VERY_VERBOSE)
printf
- ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+ ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
mctx.cltcertname);
if (ret < 0)
{
printf
- ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+ ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
mctx.cltcertname);
fflush (stdout);
return (-1);
Index: scalab01.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/scalab01.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- scalab01.c 18 Oct 2007 00:08:35 -0000 1.5
+++ scalab01.c 8 Oct 2008 17:29:04 -0000 1.6
@@ -524,8 +524,8 @@
*/
s1ctx.ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
- mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx);
+ printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%p\n",
+ mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
if (s1ctx.ldapCtx == NULL)
{
printf ("ldclt[%d]: ctrl: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -541,13 +541,13 @@
ret = ldapssl_enable_clientauth(s1ctx.ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
if (mctx.mode & VERY_VERBOSE)
printf
- ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
+ ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
if (ret < 0)
{
printf
- ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
- mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
+ ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+ mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
ldap_perror(s1ctx.ldapCtx, "ldapssl_enable_clientauth");
fflush (stdout);
return (-1);
@@ -561,8 +561,8 @@
*/
s1ctx.ldapCtx = ldap_init (mctx.hostname, mctx.port);
if (mctx.mode & VERY_VERBOSE)
- printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%08x\n",
- mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx);
+ printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%p\n",
+ mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
if (s1ctx.ldapCtx == NULL)
{
printf ("ldclt[%d]: ctrl: Cannot ldap_init (%s, %d), errno=%d\n",
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd/tools
Modified Files:
ldif.c mmldif.c pwenc.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: ldif.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldif.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ldif.c 10 Nov 2006 23:45:51 -0000 1.6
+++ ldif.c 8 Oct 2008 17:29:04 -0000 1.7
@@ -145,7 +145,7 @@
perror( "realloc" );
return( 1 );
}
- fgets(buf+curlen, maxlen/2 + 1, stdin);
+ (void)fgets(buf+curlen, maxlen/2 + 1, stdin);
}
/* we have a full line, chop potential newline and turn into ldif */
if( buf[curlen-1] == '\n' )
Index: mmldif.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/mmldif.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mmldif.c 18 Oct 2007 00:08:34 -0000 1.8
+++ mmldif.c 8 Oct 2008 17:29:04 -0000 1.9
@@ -816,7 +816,7 @@
lookahead = fgetc(edf1->fp);
if (lookahead != ' ')
break;
- fgets(line, sizeof(line), edf1->fp);
+ (void)fgets(line, sizeof(line), edf1->fp);
len = strlen(line);
for (lptr = line+len-1; len; len--, lptr--) {
if ((*lptr != '\n') && (*lptr != '\r'))
@@ -854,7 +854,7 @@
lookahead = fgetc(edf1->fp);
if (lookahead != ' ')
break;
- fgets(line, sizeof(line), edf1->fp);
+ (void)fgets(line, sizeof(line), edf1->fp);
len = strlen(line);
for (lptr = line+len-1; len; len--, lptr--) {
if ((*lptr != '\n') && (*lptr != '\r'))
Index: pwenc.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/pwenc.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- pwenc.c 19 Jun 2007 18:24:58 -0000 1.9
+++ pwenc.c 8 Oct 2008 17:29:04 -0000 1.10
@@ -145,7 +145,7 @@
fprintf( stderr, "%s\n", errorbuf );
return( NULL );
}
- slapi_ch_free((void **)&abs_configdir);
+ slapi_ch_free_string(&abs_configdir);
slapdFrontendConfig = getFrontendConfig();
if (0 == slapd_config(slapdFrontendConfig->configdir, configfile)) {
@@ -169,11 +169,9 @@
struct pw_scheme *pwsp, *cmppwsp;
extern int optind;
char *cpwd = NULL; /* candidate password for comparison */
- char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
slapdFrontendConfig_t *slapdFrontendConfig = NULL;
char *opts = "Hs:c:D:";
- char *configdir = NULL;
name = argv[ 0 ];
pwsp = cmppwsp = NULL;
@@ -409,7 +407,7 @@
rc= 1; /* OK */
}
- slapi_ch_free((void **)&buf);
+ slapi_ch_free_string(&buf);
}
return rc;
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 */
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/roles
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/roles
Modified Files:
roles_plugin.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: roles_plugin.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/roles/roles_plugin.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- roles_plugin.c 12 Oct 2007 18:03:43 -0000 1.8
+++ roles_plugin.c 8 Oct 2008 17:29:03 -0000 1.9
@@ -50,15 +50,9 @@
#include "vattr_spi.h"
#include "roles_cache.h"
+#define DEFINE_STATECHANGE_STATICS 1
#include "statechange.h"
-
-#ifdef SOURCEFILE
-#undef SOURCEFILE
-#endif
-#define SOURCEFILE "roles_plugin.c"
-static char *sourcefile = SOURCEFILE;
-
#define STATECHANGE_ROLES_ID "Roles"
#define STATECHANGE_ROLES_CONFG_FILTER "objectclass=nsRoleDefinition"
#define STATECHANGE_ROLES_ENTRY_FILTER "objectclass=*"
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/replication
Modified Files:
cl5_api.c repl5_agmt.c repl5_connection.c
repl5_protocol_util.c repl5_replica.c repl5_updatedn_list.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: cl5_api.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- cl5_api.c 19 Nov 2007 17:23:50 -0000 1.21
+++ cl5_api.c 8 Oct 2008 17:29:02 -0000 1.22
@@ -3376,8 +3376,6 @@
*/
static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
{
- PRDirEntry *entry = NULL;
- DB *thisdb = NULL;
CL5OpenMode backup;
int rc = 0;
Index: repl5_agmt.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_agmt.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- repl5_agmt.c 28 Sep 2007 22:41:09 -0000 1.12
+++ repl5_agmt.c 8 Oct 2008 17:29:02 -0000 1.13
@@ -1183,7 +1183,7 @@
{
char *this_attr = NULL;
int i = 0;
- for (i = 0; this_attr = frac_attrs[i]; i++)
+ for (i = 0; (this_attr = frac_attrs[i]); i++)
{
if (charray_inlist(verbotten_attrs,this_attr)) {
int k = 0;
Index: repl5_connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_connection.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- repl5_connection.c 18 Oct 2007 00:08:31 -0000 1.8
+++ repl5_connection.c 8 Oct 2008 17:29:03 -0000 1.9
@@ -1728,7 +1728,7 @@
char msg[SLAPI_DSE_RETURNTEXT_SIZE];
if (eqctx && !*setlevel) {
- int found = slapi_eq_cancel(eqctx);
+ (void)slapi_eq_cancel(eqctx);
}
if (s_debug_timeout && s_debug_level && *setlevel) {
Index: repl5_protocol_util.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_protocol_util.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- repl5_protocol_util.c 3 Mar 2008 18:35:11 -0000 1.12
+++ repl5_protocol_util.c 8 Oct 2008 17:29:03 -0000 1.13
@@ -417,7 +417,8 @@
}
}
}
-error:
+
+/* error: */
if (NULL != ruv_bervals)
ber_bvecfree(ruv_bervals);
if (NULL != replarea_sdn)
Index: repl5_replica.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_replica.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- repl5_replica.c 24 Jun 2008 22:22:09 -0000 1.17
+++ repl5_replica.c 8 Oct 2008 17:29:03 -0000 1.18
@@ -1076,7 +1076,7 @@
rc = csngen_adjust_time (gen, csn);
/* rc will be either CSN_SUCCESS (0) or clock skew */
-done:
+/* done: */
PR_Unlock(r->repl_lock);
if (csn != extracsn) /* do not free the given csn */
Index: repl5_updatedn_list.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_updatedn_list.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- repl5_updatedn_list.c 10 Nov 2006 23:45:17 -0000 1.5
+++ repl5_updatedn_list.c 8 Oct 2008 17:29:03 -0000 1.6
@@ -193,7 +193,7 @@
/* Bug 605169 - null ndn would cause core dump */
if ( ndn ) {
- ret = (PRBool)PL_HashTableLookupConst(hash, ndn);
+ ret = (PRBool)((uintptr_t)PL_HashTableLookupConst(hash, ndn));
}
return ret;
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/passthru
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/passthru
Modified Files:
ptconfig.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: ptconfig.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/passthru/ptconfig.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ptconfig.c 14 Nov 2007 17:53:44 -0000 1.8
+++ ptconfig.c 8 Oct 2008 17:29:02 -0000 1.9
@@ -102,7 +102,7 @@
passthru_config( int argc, char **argv )
{
int i, j, rc, tosecs, using_def_connlifetime;
- char *p, **suffixarray;
+ char **suffixarray;
PassThruServer *prevsrvr, *srvr;
PassThruSuffix *suffix, *prevsuffix;
LDAPURLDesc *ludp;
@@ -144,7 +144,7 @@
and that the url does not look like this: ldap://host
also assumes suffixes do not have any / in them
*/
- if (p = strrchr(srvr->ptsrvr_url, '/')) { /* look for last / */
+ if ((p = strrchr(srvr->ptsrvr_url, '/'))) { /* look for last / */
p = strchr(p, ' '); /* look for first space after last / */
if (p) {
if (!strchr(p, ',')) { /* no comma */
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/pwdstorage
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/pwdstorage
Modified Files:
crypt_pwd.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: crypt_pwd.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/pwdstorage/crypt_pwd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- crypt_pwd.c 10 Nov 2006 23:45:10 -0000 1.6
+++ crypt_pwd.c 8 Oct 2008 17:29:02 -0000 1.7
@@ -53,7 +53,9 @@
#else
#include <sys/socket.h>
#if defined( hpux ) || defined ( AIX ) || defined (LINUX) || defined (OSF1)
+#ifndef __USE_XOPEN
#define __USE_XOPEN /* linux */
+#endif /* __USE_XOPEN */
#include <unistd.h>
#else /* hpux */
#include <crypt.h>
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/presence
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/presence
Modified Files:
presence.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: presence.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/presence/presence.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- presence.c 10 Nov 2006 23:45:09 -0000 1.6
+++ presence.c 8 Oct 2008 17:29:02 -0000 1.7
@@ -66,13 +66,7 @@
/*** from proto-slap.h ***/
-int slapd_log_error_proc( char *subsystem, char *fmt, ... )
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)));
-#else
- ;
-#endif
-
+int slapd_log_error_proc( char *subsystem, char *fmt, ... );
/*** from ldaplog.h ***/
@@ -346,7 +340,6 @@
int presence_start( Slapi_PBlock *pb )
{
char * plugindn = NULL;
- char * httpRootDir = NULL;
LDAPDebug( LDAP_DEBUG_PLUGIN, "--> presence_start -- begin\n",0,0,0);
@@ -1105,7 +1098,6 @@
{
int status;
int props = SLAPI_ATTR_FLAG_OPATTR;
- Slapi_Attr *attr = NULL;
Slapi_ValueSet *results = NULL;
int type_name_disposition = 0;
char *actual_type_name = 0;
@@ -1150,7 +1142,6 @@
v = slapi_value_get_berval(val);
if (v) {
char *ldifvalue;
- size_t attrnamelen = strlen( attrname );
LDAPDebug( LDAP_DEBUG_PLUGIN, "----------> %s size [%d] \n",
attrname,v->bv_len,0);