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/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/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
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/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/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/dna
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/dna
Modified Files:
dna.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: dna.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/dna/dna.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- dna.c 3 Oct 2008 04:28:21 -0000 1.10
+++ dna.c 8 Oct 2008 17:29:02 -0000 1.11
@@ -55,6 +55,13 @@
#include "prclist.h"
#include "ldif.h"
+/* 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 */
+
/* get file mode flags for unix */
#ifndef _WIN32
#include <sys/stat.h>
@@ -708,7 +715,7 @@
}
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
- "----------> %s [%llu]\n", DNA_NEXTVAL, entry->nextval, 0,
+ "----------> %s [%" PRIu64 "]\n", DNA_NEXTVAL, entry->nextval, 0,
0);
value = slapi_entry_attr_get_charptr(e, DNA_PREFIX);
@@ -736,7 +743,7 @@
}
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
- "----------> %s [%llu]\n", DNA_INTERVAL, entry->interval, 0, 0);
+ "----------> %s [%" PRIu64 "]\n", DNA_INTERVAL, entry->interval, 0, 0);
#endif
value = slapi_entry_attr_get_charptr(e, DNA_GENERATE);
@@ -844,7 +851,7 @@
entry->threshold = strtoull(value, 0, 0);
slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
- "----------> %s [%llu]\n", DNA_THRESHOLD, value, 0, 0);
+ "----------> %s [%" PRIu64 "]\n", DNA_THRESHOLD, value, 0, 0);
slapi_ch_free_string(&value);
} else {
@@ -1319,8 +1326,8 @@
* don't need to do this if we already have a next range on deck. */
if ((config_entry->next_range_lower == 0) && (config_entry->remaining <= config_entry->threshold)) {
slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
- "dna_notice_allocation: Passed threshold of %llu remaining values "
- "for range %s. (%llu values remain)\n",
+ "dna_notice_allocation: Passed threshold of %" PRIu64 " remaining values "
+ "for range %s. (%" PRIu64 " values remain)\n",
config_entry->threshold, config_entry->dn, config_entry->remaining);
/* Only attempt to fix maxval if the fix flag is set. */
if (fix != 0) {
@@ -1461,13 +1468,11 @@
struct dnaServer *server,
PRUint64 *lower, PRUint64 *upper)
{
- Slapi_DN *agmt_sdn = NULL;
char *bind_dn = NULL;
char *bind_passwd = NULL;
char *bind_method = NULL;
int is_ssl = 0;
int is_client_auth = 0;
- int replport = 0;
struct berval *request = NULL;
char *retoid = NULL;
struct berval *responsedata = NULL;
@@ -1767,12 +1772,12 @@
if (prefix) {
/* The 7 below is for all of the filter characters "(&(=))"
* plus the trailing \0. The 20 is for the maximum string
- * representation of a %llu. */
+ * representation of a " PRIu64 ". */
filterlen = strlen(config_entry->filter) +
strlen(prefix) + strlen(type)
+ 7 + 20;
filter = slapi_ch_malloc(filterlen);
- snprintf(filter, filterlen, "(&%s(%s=%s%llu))",
+ snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))",
config_entry->filter, type, prefix, tmpval);
} else {
ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
@@ -1785,7 +1790,7 @@
return LDAP_OPERATIONS_ERROR;
}
- filter = slapi_ch_smprintf("(&%s(&(%s>=%llu)(%s<=%llu)))",
+ filter = slapi_ch_smprintf("(&%s(&(%s>=%" PRIu64 ")(%s<=%" PRIu64 ")))",
config_entry->filter,
type, tmpval,
type, config_entry->maxval);
@@ -1836,7 +1841,7 @@
/* filter is guaranteed to be big enough since we allocated
* enough space to fit a string representation of any unsigned
* 64-bit integer */
- snprintf(filter, filterlen, "(&%s(%s=%s%llu))",
+ snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))",
config_entry->filter, type, prefix, tmpval);
/* clear out the pblock so we can re-use it */
@@ -1968,7 +1973,7 @@
* of our current range */
if (nextval <= (config_entry->maxval + config_entry->interval)) {
/* try to set the new next value in the config entry */
- snprintf(next_value, sizeof(next_value),"%llu", nextval);
+ snprintf(next_value, sizeof(next_value),"%" PRIu64, nextval);
/* set up our replace modify operation */
replace_val[0] = next_value;
@@ -1998,7 +2003,7 @@
if (LDAP_SUCCESS == ret) {
slapi_ch_free_string(next_value_ret);
- *next_value_ret = slapi_ch_smprintf("%llu", setval);
+ *next_value_ret = slapi_ch_smprintf("%" PRIu64, setval);
if (NULL == *next_value_ret) {
ret = LDAP_OPERATIONS_ERROR;
goto done;
@@ -2045,7 +2050,7 @@
/* We store the number of remaining assigned values
* in the shared config entry. */
- snprintf(remaining_vals, sizeof(remaining_vals),"%llu", config_entry->remaining);
+ snprintf(remaining_vals, sizeof(remaining_vals),"%" PRIu64, config_entry->remaining);
/* set up our replace modify operation */
replace_val[0] = remaining_vals;
@@ -2130,7 +2135,7 @@
int ret = 0;
/* Try to set the new next range in the config entry. */
- snprintf(nextrange_value, sizeof(nextrange_value), "%llu-%llu",
+ snprintf(nextrange_value, sizeof(nextrange_value), "%" PRIu64 "-%" PRIu64,
lower, upper);
/* set up our replace modify operation */
@@ -2199,8 +2204,8 @@
int ret = 0;
/* Setup the modify operation for the config entry */
- snprintf(maxval_val, sizeof(maxval_val),"%llu", config_entry->next_range_upper);
- snprintf(nextval_val, sizeof(nextval_val),"%llu", config_entry->next_range_lower);
+ snprintf(maxval_val, sizeof(maxval_val),"%" PRIu64, config_entry->next_range_upper);
+ snprintf(nextval_val, sizeof(nextval_val),"%" PRIu64, config_entry->next_range_lower);
maxval_vals[0] = maxval_val;
maxval_vals[1] = 0;
@@ -2817,8 +2822,8 @@
char highstr[16];
/* Create the exop response */
- snprintf(lowstr, sizeof(lowstr), "%llu", lower);
- snprintf(highstr, sizeof(highstr), "%llu", upper);
+ snprintf(lowstr, sizeof(lowstr), "%" PRIu64, lower);
+ snprintf(highstr, sizeof(highstr), "%" PRIu64, upper);
range_low.bv_val = lowstr;
range_low.bv_len = strlen(range_low.bv_val);
range_high.bv_val = highstr;
@@ -2846,12 +2851,12 @@
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, respdata);
/* send the response ourselves */
- send_ldap_result( pb, ret, NULL, NULL, 0, NULL );
+ slapi_send_ldap_result( pb, ret, NULL, NULL, 0, NULL );
ret = SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
ber_bvfree(respdata);
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
- "dna_extend_exop: Released range %llu-%llu.\n",
+ "dna_extend_exop: Released range %" PRIu64 "-%" PRIu64 ".\n",
lower, upper);
}
@@ -2993,7 +2998,7 @@
*lower = *upper - release + 1;
/* try to set the new maxval in the config entry */
- snprintf(max_value, sizeof(max_value),"%llu", (*lower - 1));
+ snprintf(max_value, sizeof(max_value),"%" PRIu64, (*lower - 1));
/* set up our replace modify operation */
replace_val[0] = max_value;
@@ -3092,11 +3097,11 @@
printf("<---- filter ---------> %s\n", entry->filter);
printf("<---- prefix ---------> %s\n", entry->prefix);
printf("<---- scope ----------> %s\n", entry->scope);
- printf("<---- next value -----> %llu\n", entry->nextval);
- printf("<---- max value ------> %llu\n", entry->maxval);
- printf("<---- interval -------> %llu\n", entry->interval);
+ printf("<---- next value -----> %" PRIu64 "\n", entry->nextval);
+ printf("<---- max value ------> %" PRIu64 "\n", entry->maxval);
+ printf("<---- interval -------> %" PRIu64 "\n", entry->interval);
printf("<---- generate flag --> %s\n", entry->generate);
printf("<---- shared cfg base > %s\n", entry->shared_cfg_base);
printf("<---- shared cfg DN --> %s\n", entry->shared_cfg_dn);
- printf("<---- threshold -----> %llu", entry->threshold);
+ printf("<---- threshold ------> %" PRIu64 "", entry->threshold);
}
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);
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/chainingdb
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/chainingdb
Modified Files:
cb_instance.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: cb_instance.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/chainingdb/cb_instance.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- cb_instance.c 27 Jun 2008 19:28:22 -0000 1.9
+++ cb_instance.c 8 Oct 2008 17:29:01 -0000 1.10
@@ -903,7 +903,7 @@
static void *cb_instance_sizelimit_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->sizelimit;
@@ -916,10 +916,10 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->sizelimit=(int) value;
+ inst->sizelimit=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
if (inst->inst_be)
- be_set_sizelimit(inst->inst_be, (int) value);
+ be_set_sizelimit(inst->inst_be, (int) ((uintptr_t)value));
}
return LDAP_SUCCESS;
}
@@ -927,7 +927,7 @@
static void *cb_instance_timelimit_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->timelimit;
@@ -940,10 +940,10 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->timelimit=(int) value;
+ inst->timelimit=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
if (inst->inst_be)
- be_set_timelimit(inst->inst_be, (int) value);
+ be_set_timelimit(inst->inst_be, (int) ((uintptr_t)value));
}
return LDAP_SUCCESS;
}
@@ -951,7 +951,7 @@
static void *cb_instance_max_test_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->max_test_time;
@@ -964,7 +964,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->max_test_time=(int) value;
+ inst->max_test_time=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -973,7 +973,7 @@
static void *cb_instance_max_idle_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->max_idle_time;
@@ -986,7 +986,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->max_idle_time=(int) value;
+ inst->max_idle_time=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -996,7 +996,7 @@
static void *cb_instance_hoplimit_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->hoplimit;
@@ -1009,7 +1009,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->hoplimit=(int) value;
+ inst->hoplimit=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1018,7 +1018,7 @@
static void *cb_instance_maxbconn_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->bind_pool->conn.maxconnections;
@@ -1031,7 +1031,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->bind_pool->conn.maxconnections=(int) value;
+ inst->bind_pool->conn.maxconnections=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1040,7 +1040,7 @@
static void *cb_instance_maxconn_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->pool->conn.maxconnections;
@@ -1053,7 +1053,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->pool->conn.maxconnections=(int) value;
+ inst->pool->conn.maxconnections=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1062,7 +1062,7 @@
static void *cb_instance_abandonto_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->abandon_timeout.tv_sec;
@@ -1084,7 +1084,7 @@
}
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->abandon_timeout.tv_sec=(int) value;
+ inst->abandon_timeout.tv_sec=(int) ((uintptr_t)value);
inst->abandon_timeout.tv_usec=0;
PR_RWLock_Unlock(inst->rwl_config_lock);
}
@@ -1094,7 +1094,7 @@
static void *cb_instance_maxbconc_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->bind_pool->conn.maxconcurrency;
@@ -1107,7 +1107,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->bind_pool->conn.maxconcurrency=(int) value;
+ inst->bind_pool->conn.maxconcurrency=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1116,7 +1116,7 @@
static void *cb_instance_maxconc_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->pool->conn.maxconcurrency;
@@ -1129,7 +1129,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->pool->conn.maxconcurrency=(int) value;
+ inst->pool->conn.maxconcurrency=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1138,7 +1138,7 @@
static void *cb_instance_imperson_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data = inst->impersonate;
@@ -1153,7 +1153,7 @@
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->impersonate=(int) value;
+ inst->impersonate=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
} else {
/* Security check: Make sure the proxing user is */
@@ -1162,7 +1162,7 @@
char * rootdn=cb_get_rootdn();
PR_RWLock_Rlock(inst->rwl_config_lock);
- if (((int) value) && inst->pool && inst->pool->binddn &&
+ if (((int) ((uintptr_t)value)) && inst->pool && inst->pool->binddn &&
!strcmp(inst->pool->binddn,rootdn)) { /* UTF-8 aware */
rc=LDAP_UNWILLING_TO_PERFORM;
if (errorbuf)
@@ -1179,7 +1179,7 @@
static void *cb_instance_connlife_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->pool->conn.connlifetime;
@@ -1192,7 +1192,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->pool->conn.connlifetime=(int) value;
+ inst->pool->conn.connlifetime=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1201,7 +1201,7 @@
static void *cb_instance_bindto_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->bind_pool->conn.op_timeout.tv_sec;
@@ -1214,12 +1214,12 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->bind_pool->conn.op_timeout.tv_sec=(int) value;
+ inst->bind_pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value);
inst->bind_pool->conn.op_timeout.tv_usec=0;
- inst->bind_pool->conn.bind_timeout.tv_sec=(int) value;
+ inst->bind_pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value);
inst->bind_pool->conn.bind_timeout.tv_usec=0;
/* Used to bind to the farm server */
- inst->pool->conn.bind_timeout.tv_sec=(int) value;
+ inst->pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value);
inst->pool->conn.bind_timeout.tv_usec=0;
PR_RWLock_Unlock(inst->rwl_config_lock);
}
@@ -1229,7 +1229,7 @@
static void *cb_instance_opto_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->pool->conn.op_timeout.tv_sec;
@@ -1242,7 +1242,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->pool->conn.op_timeout.tv_sec=(int) value;
+ inst->pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value);
inst->pool->conn.op_timeout.tv_usec=0;
PR_RWLock_Unlock(inst->rwl_config_lock);
}
@@ -1252,7 +1252,7 @@
static void *cb_instance_ref_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->searchreferral;
@@ -1265,7 +1265,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->searchreferral=(int) value;
+ inst->searchreferral=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1274,7 +1274,7 @@
static void *cb_instance_acl_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->local_acl;
@@ -1295,7 +1295,7 @@
return LDAP_SUCCESS;
}
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->local_acl=(int) value;
+ inst->local_acl=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1304,7 +1304,7 @@
static void *cb_instance_bindretry_get(void *arg)
{
cb_backend_instance * inst=(cb_backend_instance *) arg;
- int data;
+ uintptr_t data;
PR_RWLock_Rlock(inst->rwl_config_lock);
data=inst->bind_retry;
@@ -1317,7 +1317,7 @@
cb_backend_instance * inst=(cb_backend_instance *) arg;
if (apply) {
PR_RWLock_Wlock(inst->rwl_config_lock);
- inst->bind_retry=(int) value;
+ inst->bind_retry=(int) ((uintptr_t)value);
PR_RWLock_Unlock(inst->rwl_config_lock);
}
return LDAP_SUCCESS;
@@ -1383,7 +1383,7 @@
} else {
int_val = cb_atoi((char *)bval->bv_val);
}
- retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+ retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
break;
case CB_CONFIG_TYPE_INT_OCTAL:
if (use_default) {
@@ -1391,7 +1391,7 @@
} else {
int_val = (int) strtol((char *)bval->bv_val, NULL, 8);
}
- retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+ retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
break;
case CB_CONFIG_TYPE_LONG:
if (use_default) {
@@ -1414,7 +1414,7 @@
} else {
int_val = !strcasecmp((char *) bval->bv_val, "on");
}
- retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+ retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
break;
}
return retval;
@@ -1435,10 +1435,10 @@
switch(config->config_type) {
case CB_CONFIG_TYPE_INT:
- sprintf(buf, "%d", (int) config->config_get_fn(arg));
+ sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg)));
break;
case CB_CONFIG_TYPE_INT_OCTAL:
- sprintf(buf, "%o", (int) config->config_get_fn(arg));
+ sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg)));
break;
case CB_CONFIG_TYPE_LONG:
sprintf(buf, "%ld", (long) config->config_get_fn(arg));
@@ -1451,7 +1451,7 @@
slapi_ch_free((void **)&tmp_string);
break;
case CB_CONFIG_TYPE_ONOFF:
- if ((int) config->config_get_fn(arg)) {
+ if ((int) ((uintptr_t)config->config_get_fn(arg))) {
sprintf(buf,"%s","on");
} else {
sprintf(buf,"%s","off");