[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools/rsearch infadd.c, 1.6, 1.7 rsearch.c, 1.4, 1.5 searchthread.c, 1.5, 1.6
by Richard Allen Megginson
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;
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools/ldclt ldapfct.c, 1.7, 1.8 scalab01.c, 1.5, 1.6
by Richard Allen Megginson
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",
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm back-ldbm.h, 1.15, 1.16 dblayer.c, 1.27, 1.28 dbverify.c, 1.2, 1.3 import-merge.c, 1.8, 1.9 import-threads.c, 1.15, 1.16 import.c, 1.11, 1.12 import.h, 1.8, 1.9 ldbm_attr.c, 1.10, 1.11 ldbm_config.c, 1.14, 1.15 ldbm_instance_config.c, 1.10, 1.11 ldbm_modify.c, 1.6, 1.7 ldif2ldbm.c, 1.16, 1.17 monitor.c, 1.7, 1.8 parents.c, 1.5, 1.6 perfctrs.c, 1.9, 1.10
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd/back-ldbm
Modified Files:
back-ldbm.h dblayer.c dbverify.c import-merge.c
import-threads.c import.c import.h ldbm_attr.c ldbm_config.c
ldbm_instance_config.c ldbm_modify.c ldif2ldbm.c monitor.c
parents.c perfctrs.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: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- back-ldbm.h 5 Aug 2008 21:03:42 -0000 1.15
+++ back-ldbm.h 8 Oct 2008 17:29:03 -0000 1.16
@@ -114,6 +114,15 @@
#define MEGABYTE (1024 * 1024)
#define GIGABYTE (1024 * MEGABYTE)
+#define DB_USES_LOCKING(env) \
+ (DB_INIT_LOCK & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_TRANSACTIONS(env) \
+ (DB_INIT_TXN & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_MPOOL(env) \
+ (DB_INIT_MPOOL & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_LOGGING(env) \
+ (DB_INIT_LOG & ((env)->get_open_flags((env), NULL)))
+
/* include NSPR header files */
#include "nspr.h"
Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- dblayer.c 3 Apr 2008 16:52:47 -0000 1.27
+++ dblayer.c 8 Oct 2008 17:29:03 -0000 1.28
@@ -97,6 +97,13 @@
#include "dblayer.h"
#include <prrwlock.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 */
+
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4100
#define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval) \
{ \
@@ -284,7 +291,7 @@
int
dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase, int apply) {
- int val = (int) value;
+ int val = (int)((uintptr_t)value);
int retval = LDAP_SUCCESS;
if (apply) {
@@ -304,7 +311,7 @@
void *
dblayer_get_batch_transactions(void *arg) {
- return (void *)trans_batch_limit;
+ return (void *)((uintptr_t)trans_batch_limit);
}
@@ -465,25 +472,25 @@
}
-/* Helper function for large seeks, db2.4 */
-static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno,
- u_long relative, int isrewind, int whence)
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+/* Helper function for large seeks, db4.3 */
+static int dblayer_seek43_large(int fd, off64_t offset, int whence)
{
- off64_t offset = 0, ret;
+ int ret = 0;
- offset = (off64_t)pgsize * pageno + relative;
- if (isrewind) offset = -offset;
ret = lseek64(fd, offset, whence);
return (ret < 0) ? errno : 0;
}
-
-#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
-/* Helper function for large seeks, db4.3 */
-static int dblayer_seek43_large(int fd, off64_t offset, int whence)
+#else
+/* Helper function for large seeks, db2.4 */
+static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno,
+ u_long relative, int isrewind, int whence)
{
- int ret = 0;
+ off64_t offset = 0, ret;
+ offset = (off64_t)pgsize * pageno + relative;
+ if (isrewind) offset = -offset;
ret = lseek64(fd, offset, whence);
return (ret < 0) ? errno : 0;
@@ -892,7 +899,7 @@
if (feof(f))
break;
if (strncmp(s, "VmSize:", 7) == 0) {
- sscanf(s+7, "%d", procpages);
+ sscanf(s+7, "%" PRIuPTR, procpages);
break;
}
}
@@ -3449,7 +3456,7 @@
{
if (priv->dblayer_enable_transactions)
{
- if (NULL != priv->dblayer_env->dblayer_DB_ENV->lk_handle) {
+ if (DB_USES_LOCKING(priv->dblayer_env->dblayer_DB_ENV)) {
int aborted;
if ((rval = LOCK_DETECT(priv->dblayer_env->dblayer_DB_ENV,
0,
@@ -3619,7 +3626,7 @@
checkpoint_interval)
continue;
- if (NULL == priv->dblayer_env->dblayer_DB_ENV->tx_handle)
+ if (!DB_USES_TRANSACTIONS(priv->dblayer_env->dblayer_DB_ENV))
continue;
/* now checkpoint */
@@ -3777,7 +3784,7 @@
DS_Sleep(interval); /* 622855: wait for other threads fully started */
if (priv->dblayer_enable_transactions)
{
- if ( (NULL != priv->dblayer_env->dblayer_DB_ENV->mp_handle) &&
+ if ( DB_USES_MPOOL(priv->dblayer_env->dblayer_DB_ENV) &&
(0 != priv->dblayer_trickle_percentage) )
{
int pages_written = 0;
Index: dbverify.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dbverify.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dbverify.c 18 Oct 2007 00:08:34 -0000 1.2
+++ dbverify.c 8 Oct 2008 17:29:03 -0000 1.3
@@ -50,7 +50,6 @@
char *filep = NULL;
PRDir *dirhandle = NULL;
PRDirEntry *direntry = NULL;
- backend *be = inst->inst_be;
DB *dbp = NULL;
int tmplen = 0;
int filelen = 0;
@@ -87,7 +86,6 @@
(direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT)))
{
/* struct attrinfo *ai = NULL; */
- char *p = NULL;
dbp = NULL;
if (!direntry->name)
Index: import-merge.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-merge.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- import-merge.c 2 Oct 2007 18:39:51 -0000 1.8
+++ import-merge.c 8 Oct 2008 17:29:03 -0000 1.9
@@ -49,6 +49,13 @@
#include "back-ldbm.h"
#include "import.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 */
+
struct _import_merge_thang
{
int type;
@@ -667,7 +674,7 @@
if (1 == job->number_indexers) {
import_log_notice(job, "Beginning %d-way merge of one file...", passes);
} else {
- import_log_notice(job, "Beginning %d-way merge of up to %lu files...",
+ import_log_notice(job, "Beginning %d-way merge of up to %" PRIuPTR " files...",
passes, job->number_indexers);
}
Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- import-threads.c 25 Jan 2008 00:59:00 -0000 1.15
+++ import-threads.c 8 Oct 2008 17:29:03 -0000 1.16
@@ -49,6 +49,13 @@
* a wire import (aka "fast replica" import) won't have a producer thread.
*/
+/* 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 */
+
#include "back-ldbm.h"
#include "vlv_srch.h"
#include "import.h"
@@ -56,6 +63,7 @@
#define STDIN_FILENO 0
#endif
+static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize);
static struct backentry *import_make_backentry(Slapi_Entry *e, ID id)
{
@@ -570,8 +578,8 @@
"ending line %d of file \"%s\"",
escape_string(slapi_entry_get_dn(e), ebuf),
curr_lineno, curr_filename);
- import_log_notice(job, "REASON: entry too large (%d bytes) for "
- "the buffer size (%d bytes)", newesize, job->fifo.bsize);
+ import_log_notice(job, "REASON: entry too large (%ld bytes) for "
+ "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
backentry_free(&ep);
job->skipped++;
continue;
@@ -804,8 +812,8 @@
char ebuf[BUFSIZ];
import_log_notice(job, "WARNING: skipping entry \"%s\"",
escape_string(slapi_entry_get_dn(e), ebuf));
- import_log_notice(job, "REASON: entry too large (%d bytes) for "
- "the buffer size (%d bytes)", newesize, job->fifo.bsize);
+ import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for "
+ "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
backentry_free(&ep);
job->skipped++;
continue;
@@ -1185,7 +1193,7 @@
int idl_disposition = 0;
struct vlvIndex* vlv_index = NULL;
void *substring_key_buffer = NULL;
- FifoItem *fi;
+ FifoItem *fi = NULL;
int is_objectclass_attribute;
int is_nsuniqueid_attribute;
void *attrlist_cursor;
@@ -1598,8 +1606,8 @@
char ebuf[BUFSIZ];
import_log_notice(job, "WARNING: skipping entry \"%s\"",
escape_string(slapi_entry_get_dn(ep->ep_entry), ebuf));
- import_log_notice(job, "REASON: entry too large (%d bytes) for "
- "the import buffer size (%d bytes). Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
+ import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for "
+ "the import buffer size (%" PRIuPTR " bytes). Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
backentry_clear_entry(ep); /* entry is released in the frontend on failure*/
backentry_free( &ep ); /* release the backend wrapper, here */
PR_Unlock(job->wire_lock);
@@ -1670,7 +1678,7 @@
{
struct ldbminfo *li;
backend *be = NULL;
- ImportJob *job;
+ ImportJob *job = NULL;
PRThread *thread;
int state;
@@ -1954,7 +1962,7 @@
if (entry_filter != NULL) /* Single instance restoration */
{
- if (!(int)strstr(estr, entry_filter))
+ if (NULL == strstr(estr, entry_filter))
continue;
}
Index: import.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- import.c 3 Apr 2008 16:52:47 -0000 1.11
+++ import.c 8 Oct 2008 17:29:03 -0000 1.12
@@ -46,6 +46,12 @@
* please make sure you use 4-space indentation on this file.
*/
+/* 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 */
#include "back-ldbm.h"
#include "vlv_srch.h"
@@ -1149,7 +1155,7 @@
import_log_notice(job, "Index buffering is disabled.");
else
import_log_notice(job,
- "Index buffering enabled with bucket size %lu",
+ "Index buffering enabled with bucket size %" PRIuPTR,
job->job_index_buffer_suggestion);
job->worker_list = producer;
@@ -1312,7 +1318,7 @@
if (job->not_here_skipped)
{
if (job->skipped)
- import_log_notice(job, "Import complete. Processed %lu entries "
+ import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries "
"(%d bad entries were skipped, "
"%d entries were skipped because they don't "
"belong to this database) in %d seconds. "
@@ -1320,7 +1326,7 @@
job->skipped, job->not_here_skipped,
seconds_to_import, entries_per_second);
else
- import_log_notice(job, "Import complete. Processed %lu entries "
+ import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries "
"(%d entries were skipped because they don't "
"belong to this database) "
"in %d seconds. (%.2f entries/sec)",
@@ -1330,13 +1336,13 @@
else
{
if (job->skipped)
- import_log_notice(job, "Import complete. Processed %lu entries "
+ import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries "
"(%d were skipped) in %d seconds. "
"(%.2f entries/sec)", entries_processed,
job->skipped, seconds_to_import,
entries_per_second);
else
- import_log_notice(job, "Import complete. Processed %lu entries "
+ import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries "
"in %d seconds. (%.2f entries/sec)",
entries_processed, seconds_to_import,
entries_per_second);
Index: import.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- import.h 10 Nov 2006 23:45:39 -0000 1.8
+++ import.h 8 Oct 2008 17:29:03 -0000 1.9
@@ -235,4 +235,3 @@
void index_producer(void *param);
void import_foreman(void *param);
void import_worker(void *param);
-static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize);
Index: ldbm_attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_attr.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_attr.c 15 Jul 2008 16:49:43 -0000 1.10
+++ ldbm_attr.c 8 Oct 2008 17:29:03 -0000 1.11
@@ -258,16 +258,16 @@
preamble, officialOID, index_rules[j] );
slapi_ch_free((void**)&preamble);
}
- } else if (p =
- strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN)) {
+ } else if ((p =
+ strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN))) {
_set_attr_substrlen(INDEX_SUBSTRBEGIN, index_rules[j],
&substrlens);
- } else if (p =
- strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE)) {
+ } else if ((p =
+ strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE))) {
_set_attr_substrlen(INDEX_SUBSTRMIDDLE, index_rules[j],
&substrlens);
- } else if (p =
- strstr(index_rules[j], INDEX_ATTR_SUBSTREND)) {
+ } else if ((p =
+ strstr(index_rules[j], INDEX_ATTR_SUBSTREND))) {
_set_attr_substrlen(INDEX_SUBSTREND, index_rules[j],
&substrlens);
} else if (!slapi_matchingrule_is_ordering(index_rules[j], attrsyntax_oid)) {
Index: ldbm_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_config.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ldbm_config.c 4 Dec 2007 00:50:19 -0000 1.14
+++ ldbm_config.c 8 Oct 2008 17:29:03 -0000 1.15
@@ -42,6 +42,13 @@
/* ldbm_config.c - Handles configuration information that is global to all ldbm instances. */
+/* 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 */
+
#include "back-ldbm.h"
#include "dblayer.h"
@@ -147,14 +154,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) (li->li_lookthroughlimit);
+ return (void *) ((uintptr_t)(li->li_lookthroughlimit));
}
static int ldbm_config_lookthroughlimit_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
/* Do whatever we can to make sure the data is ok. */
@@ -169,14 +176,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) (li->li_mode);
+ return (void *) ((uintptr_t)(li->li_mode));
}
static int ldbm_config_mode_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
/* Do whatever we can to make sure the data is ok. */
@@ -191,14 +198,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) (li->li_allidsthreshold);
+ return (void *) ((uintptr_t)(li->li_allidsthreshold));
}
static int ldbm_config_allidsthreshold_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
/* Do whatever we can to make sure the data is ok. */
@@ -365,14 +372,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) (li->li_maxpassbeforemerge);
+ return (void *) ((uintptr_t)(li->li_maxpassbeforemerge));
}
static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
if (val < 0) {
@@ -391,14 +398,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) (li->li_new_dbncache);
+ return (void *) ((uintptr_t)(li->li_new_dbncache));
}
static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
if (val < 0) {
@@ -454,14 +461,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_durable_transactions;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_durable_transactions);
}
static int ldbm_config_db_durable_transactions_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_durable_transactions = val;
@@ -474,7 +481,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_lockdown;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lockdown);
}
static int ldbm_config_db_lockdown_set(
@@ -487,7 +494,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_lockdown = val;
@@ -500,14 +507,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_circular_logging;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_circular_logging);
}
static int ldbm_config_db_circular_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_circular_logging = val;
@@ -520,14 +527,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_enable_transactions;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_enable_transactions);
}
static int ldbm_config_db_transaction_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_enable_transactions = val;
@@ -560,14 +567,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_checkpoint_interval;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_checkpoint_interval);
}
static int ldbm_config_db_checkpoint_interval_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_checkpoint_interval = val;
@@ -620,14 +627,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_idl_divisor;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_idl_divisor);
}
static int ldbm_config_db_idl_divisor_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_idl_divisor = val;
@@ -660,14 +667,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_spin_count;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_spin_count);
}
static int ldbm_config_db_spin_count_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_spin_count = val;
@@ -680,14 +687,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_trickle_percentage;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_trickle_percentage);
}
static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (val < 0 || val > 100) {
PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
@@ -707,14 +714,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_verbose;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_verbose);
}
static int ldbm_config_db_verbose_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_verbose = val;
@@ -727,14 +734,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_debug;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_debug);
}
static int ldbm_config_db_debug_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_debug = val;
@@ -747,14 +754,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_named_regions;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_named_regions);
}
static int ldbm_config_db_named_regions_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_named_regions = val;
@@ -767,14 +774,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_private_mem;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_mem);
}
static int ldbm_config_db_private_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_private_mem = val;
@@ -787,14 +794,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_private_import_mem;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_import_mem);
}
static int ldbm_config_db_private_import_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_private_import_mem = val;
@@ -820,7 +827,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_shm_key = val;
@@ -833,7 +840,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_lock_config;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lock_config);
}
@@ -859,14 +866,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_cache_config;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_cache_config);
}
static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_cache_config = val;
@@ -879,14 +886,14 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->db_debug_checkpointing;
+ return (void *) ((uintptr_t)li->li_dblayer_private->db_debug_checkpointing);
}
static int ldbm_config_db_debug_checkpointing_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->db_debug_checkpointing = val;
@@ -922,7 +929,7 @@
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_import_cache_autosize);
+ return (void *)((uintptr_t)(li->li_import_cache_autosize));
}
static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf,
@@ -931,7 +938,7 @@
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_import_cache_autosize = (int)value;
+ li->li_import_cache_autosize = (int)((uintptr_t)value);
return LDAP_SUCCESS;
}
@@ -939,7 +946,7 @@
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_cache_autosize);
+ return (void *)((uintptr_t)(li->li_cache_autosize));
}
static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf,
@@ -948,7 +955,7 @@
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_cache_autosize = (int)value;
+ li->li_cache_autosize = (int)((uintptr_t)value);
return LDAP_SUCCESS;
}
@@ -956,7 +963,7 @@
{
struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_cache_autosize_split);
+ return (void *)((uintptr_t)(li->li_cache_autosize_split));
}
static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf,
@@ -965,7 +972,7 @@
struct ldbminfo *li = (struct ldbminfo *)arg;
if (apply)
- li->li_cache_autosize_split = (int)value;
+ li->li_cache_autosize_split = (int)((uintptr_t)value);
return LDAP_SUCCESS;
}
@@ -1021,7 +1028,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_fat_lock;
+ return (void *) ((uintptr_t)li->li_fat_lock);
}
static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf,
@@ -1030,7 +1037,7 @@
struct ldbminfo *li = (struct ldbminfo *) arg;
if (apply) {
- li->li_fat_lock = (int) value;
+ li->li_fat_lock = (int) ((uintptr_t)value);
}
return LDAP_SUCCESS;
@@ -1040,7 +1047,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_legacy_errcode;
+ return (void *) ((uintptr_t)li->li_legacy_errcode);
}
static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf,
@@ -1049,7 +1056,7 @@
struct ldbminfo *li = (struct ldbminfo *) arg;
if (apply) {
- li->li_legacy_errcode = (int) value;
+ li->li_legacy_errcode = (int) ((uintptr_t)value);
}
return LDAP_SUCCESS;
@@ -1099,7 +1106,7 @@
static int ldbm_config_set_use_vlv_index(void *arg, void *value, char *errorbuf, int phase, int apply)
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
if (val) {
@@ -1115,7 +1122,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_use_vlv;
+ return (void *) ((uintptr_t)li->li_use_vlv);
}
static int
@@ -1174,7 +1181,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_tx_max;
+ return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_tx_max);
}
static int ldbm_config_db_tx_max_set(
@@ -1187,7 +1194,7 @@
{
struct ldbminfo *li = (struct ldbminfo *) arg;
int retval = LDAP_SUCCESS;
- int val = (int) value;
+ int val = (int) ((uintptr_t)value);
if (apply) {
li->li_dblayer_private->dblayer_tx_max = val;
@@ -1409,17 +1416,17 @@
switch(config->config_type) {
case 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 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 CONFIG_TYPE_LONG:
sprintf(buf, "%ld", (long) config->config_get_fn(arg));
break;
case CONFIG_TYPE_SIZE_T:
val = (size_t) config->config_get_fn(arg);
- sprintf(buf, "%lu", val);
+ sprintf(buf, "%" PRIuPTR, val);
break;
case CONFIG_TYPE_STRING:
/* Remember the get function for strings returns memory
@@ -1429,7 +1436,7 @@
slapi_ch_free((void **)&tmp_string);
break;
case CONFIG_TYPE_ONOFF:
- if ((int) config->config_get_fn(arg)) {
+ if ((int) ((uintptr_t)config->config_get_fn(arg))) {
sprintf(buf, "on");
} else {
sprintf(buf, "off");
@@ -1578,7 +1585,7 @@
}
/* convert 64 bit value to 32 bit value */
LL_L2I(int_val, llval);
- 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 CONFIG_TYPE_INT_OCTAL:
if (use_default) {
@@ -1586,7 +1593,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 CONFIG_TYPE_LONG:
if (use_default) {
@@ -1657,7 +1664,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;
}
Index: ldbm_instance_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_instance_config.c 4 Dec 2007 00:50:19 -0000 1.10
+++ ldbm_instance_config.c 8 Oct 2008 17:29:04 -0000 1.11
@@ -136,7 +136,7 @@
{
ldbm_instance *inst = (ldbm_instance *)arg;
- return (void *)inst->inst_be->be_readonly;
+ return (void *)((uintptr_t)inst->inst_be->be_readonly);
}
static void *
@@ -165,7 +165,7 @@
{
ldbm_instance *inst = (ldbm_instance *)arg;
- return (void *)inst->require_index;
+ return (void *)((uintptr_t)inst->require_index);
}
static int
@@ -219,6 +219,7 @@
ldbm_instance_config_readonly_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
ldbm_instance *inst = (ldbm_instance *)arg;
+ uintptr_t pval = (uintptr_t)value;
if (!apply) {
return LDAP_SUCCESS;
@@ -229,15 +230,15 @@
* but won't change them until the instance is un-busy again.
*/
if (! (inst->inst_flags & INST_FLAG_BUSY)) {
- slapi_mtn_be_set_readonly(inst->inst_be, (int)value);
+ slapi_mtn_be_set_readonly(inst->inst_be, (int)pval);
}
- if ((int)value) {
+ if ((int)pval) {
inst->inst_flags |= INST_FLAG_READONLY;
} else {
inst->inst_flags &= ~INST_FLAG_READONLY;
}
} else {
- slapi_be_set_readonly(inst->inst_be, (int)value);
+ slapi_be_set_readonly(inst->inst_be, (int)pval);
}
return LDAP_SUCCESS;
@@ -252,7 +253,7 @@
return LDAP_SUCCESS;
}
- inst->require_index = (int)value;
+ inst->require_index = (int)((uintptr_t)value);
return LDAP_SUCCESS;
}
Index: ldbm_modify.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_modify.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ldbm_modify.c 18 Oct 2007 22:40:18 -0000 1.6
+++ ldbm_modify.c 8 Oct 2008 17:29:04 -0000 1.7
@@ -578,10 +578,10 @@
*/
for ( j = 0; j < smods->num_mods - 1; j++ ) {
if ( (mod = smods->mods[j]) != NULL ) {
- if ( (mod->mod_op & LDAP_MOD_REPLACE) == 0 ||
- mod->mod_vals.modv_bvals &&
- strcasecmp (mod->mod_type, "modifiersname") &&
- strcasecmp (mod->mod_type, "modifytime") ) {
+ if ( ((mod->mod_op & LDAP_MOD_REPLACE) == 0) ||
+ (mod->mod_vals.modv_bvals &&
+ strcasecmp (mod->mod_type, "modifiersname") &&
+ strcasecmp (mod->mod_type, "modifytime") ) ) {
goto done;
}
}
@@ -589,9 +589,9 @@
if ( entry && entry->e_sdn.dn ) {
for ( j = 0; j < smods->num_mods - 1; j++ ) {
- if ( (mod = smods->mods[j]) != NULL &&
- strcasecmp (mod->mod_type, "modifiersname") &&
- strcasecmp (mod->mod_type, "modifytime") ) {
+ if ( ((mod = smods->mods[j]) != NULL) &&
+ strcasecmp (mod->mod_type, "modifiersname") &&
+ strcasecmp (mod->mod_type, "modifytime") ) {
for ( attr = entry->e_attrs; attr; attr = attr->a_next ) {
/* Mods have effect if at least a null-value-mod is
* to actually remove an existing attribute
Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ldif2ldbm.c 3 Apr 2008 16:52:47 -0000 1.16
+++ ldif2ldbm.c 8 Oct 2008 17:29:04 -0000 1.17
@@ -47,6 +47,13 @@
* code for db2index (is this still in use?)
*/
+/* 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 */
+
#include "back-ldbm.h"
#include "vlv_srch.h"
#include "dblayer.h"
@@ -76,7 +83,7 @@
static PRIntn import_subcount_hash_compare_keys(const void *v1, const void *v2)
{
- return( ((ID)v1 == (ID)v2 ) ? 1 : 0);
+ return( ((ID)((uintptr_t)v1) == (ID)((uintptr_t)v2) ) ? 1 : 0);
}
static PRIntn import_subcount_hash_compare_values(const void *v1, const void *v2)
@@ -86,7 +93,7 @@
static PLHashNumber import_subcount_hash_fn(const void *id)
{
- return (PLHashNumber) id;
+ return (PLHashNumber) ((uintptr_t)id);
}
void import_subcount_stuff_init(import_subcount_stuff *stuff)
@@ -263,7 +270,7 @@
size_t count)
{
PR_ASSERT(NULL == PL_HashTableLookup(mothers->hashtable,(void*)parent_id));
- PL_HashTableAdd(mothers->hashtable,(void*)parent_id,(void*)count);
+ PL_HashTableAdd(mothers->hashtable,(void*)((uintptr_t)parent_id),(void*)count);
return 0;
}
@@ -276,7 +283,7 @@
*count = 0;
/* Lookup hash table for ID */
stored_count = (size_t)PL_HashTableLookup(mothers->hashtable,
- (void*)parent_id);
+ (void*)((uintptr_t)parent_id));
/* If present, return the count found */
if (0 != stored_count) {
*count = stored_count;
@@ -292,11 +299,11 @@
/* Lookup the hash table for the target ID */
stored_count = (size_t)PL_HashTableLookup(mothers->hashtable,
- (void*)parent_id);
+ (void*)((uintptr_t)parent_id));
PR_ASSERT(0 != stored_count);
/* Increment the count */
stored_count++;
- PL_HashTableAdd(mothers->hashtable, (void*)parent_id, (void*)stored_count);
+ PL_HashTableAdd(mothers->hashtable, (void*)((uintptr_t)parent_id), (void*)stored_count);
return 0;
}
@@ -320,7 +327,7 @@
* let's do it so we can reuse the modify routines) */
cache_lock_entry( &inst->inst_cache, e );
modify_init(&mc,e);
- sprintf(value_buffer,"%lu",sub_count);
+ sprintf(value_buffer,"%" PRIuPTR,sub_count);
/* attr numsubordinates could already exist in the entry,
let's check whether it's already there or not */
isreplace = (attrlist_find(e->ep_entry->e_attrs, numsubordinates) != NULL);
@@ -761,12 +768,12 @@
int appendmode = 0;
int appendmode_1 = 0;
int noversion = 0;
- ID lastid;
+ ID lastid = 0;
int task_flags;
Slapi_Task *task;
int run_from_cmdline = 0;
char *instance_name;
- ldbm_instance *inst;
+ ldbm_instance *inst = NULL;
int str2entry_options= 0;
int retry;
int we_start_the_backends = 0;
@@ -1812,7 +1819,6 @@
dbc->c_close(dbc);
}
if (return_value < 0) {/* error case: undo vlv indexing */
- struct vlvIndex *vlvip = NULL;
/* if jumped to out due to an error, vlv lock has not been released */
for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
vlvIndex_go_offline(pvlv[vlvidx], be);
Index: monitor.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/monitor.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- monitor.c 10 Nov 2006 23:45:39 -0000 1.7
+++ monitor.c 8 Oct 2008 17:29:04 -0000 1.8
@@ -42,6 +42,13 @@
/* monitor.c - ldbm backend monitor function */
+/* 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 */
+
#include "back-ldbm.h"
#include "dblayer.h" /* XXXmcs: not sure this is good to do... */
#include <sys/stat.h>
@@ -117,9 +124,9 @@
MSET("entryCacheTries");
sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
MSET("entryCacheHitRatio");
- sprintf(buf, "%lu", size);
+ sprintf(buf, "%" PRIuPTR, size);
MSET("currentEntryCacheSize");
- sprintf(buf, "%lu", maxsize);
+ sprintf(buf, "%" PRIuPTR, maxsize);
MSET("maxEntryCacheSize");
sprintf(buf, "%ld", nentries);
MSET("currentEntryCacheCount");
Index: parents.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/parents.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- parents.c 10 Nov 2006 23:45:39 -0000 1.5
+++ parents.c 8 Oct 2008 17:29:04 -0000 1.6
@@ -44,6 +44,13 @@
#include "back-ldbm.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 */
+
char *numsubordinates = "numsubordinates";
char *hassubordinates = "hassubordinates";
@@ -130,7 +137,7 @@
else
{
char value_buffer[20]; /* enough digits for 2^64 children */
- sprintf(value_buffer,"%lu", current_sub_count);
+ sprintf(value_buffer,"%" PRIuPTR, current_sub_count);
slapi_mods_add(smods, mod_op | LDAP_MOD_BVALUES, numsubordinates, strlen(value_buffer), value_buffer);
}
ret = modify_apply_mods(mc,smods); /* smods passed in */
Index: perfctrs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/perfctrs.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- perfctrs.c 26 Sep 2007 17:32:41 -0000 1.9
+++ perfctrs.c 8 Oct 2008 17:29:04 -0000 1.10
@@ -296,7 +296,7 @@
return;
}
/* Call libdb to get the various stats */
- if (NULL != db_env->lg_handle)
+ if (DB_USES_LOGGING(db_env))
{
DB_LOG_STAT *logstat = NULL;
ret = LOG_STAT(db_env,&logstat,0,malloc);
@@ -307,7 +307,7 @@
}
free(logstat);
}
- if (NULL != db_env->tx_handle)
+ if (DB_USES_TRANSACTIONS(db_env))
{
DB_TXN_STAT *txnstat = NULL;
ret = TXN_STAT(db_env, &txnstat, 0, malloc);
@@ -320,7 +320,7 @@
if (txnstat)
free(txnstat);
}
- if (NULL != db_env->lk_handle)
+ if (DB_USES_LOCKING(db_env))
{
DB_LOCK_STAT *lockstat = NULL;
ret = LOCK_STAT(db_env,&lockstat,0,malloc);
@@ -338,7 +338,7 @@
}
free(lockstat);
}
- if (NULL != db_env->mp_handle)
+ if (DB_USES_MPOOL(db_env))
{
DB_MPOOL_STAT *mpstat = NULL;
ret = MEMP_STAT(db_env,&mpstat,NULL,0,malloc);
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools ldif.c, 1.6, 1.7 mmldif.c, 1.8, 1.9 pwenc.c, 1.9, 1.10
by Richard Allen Megginson
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;
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/roles roles_plugin.c, 1.8, 1.9
by Richard Allen Megginson
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=*"
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication cl5_api.c, 1.21, 1.22 repl5_agmt.c, 1.12, 1.13 repl5_connection.c, 1.8, 1.9 repl5_protocol_util.c, 1.12, 1.13 repl5_replica.c, 1.17, 1.18 repl5_updatedn_list.c, 1.5, 1.6
by Richard Allen Megginson
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;
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd agtmmap.c, 1.10, 1.11 auth.c, 1.10, 1.11 bind.c, 1.13, 1.14 config.c, 1.11, 1.12 configdse.c, 1.8, 1.9 conntable.c, 1.9, 1.10 detach.c, 1.7, 1.8 dse.c, 1.9, 1.10 filter.c, 1.9, 1.10 libglobs.c, 1.24, 1.25 log.c, 1.22, 1.23 log.h, 1.7, 1.8 main.c, 1.24, 1.25 mapping_tree.c, 1.14, 1.15 pblock.c, 1.16, 1.17 saslbind.c, 1.26, 1.27 snmp_collator.c, 1.13, 1.14 statechange.h, 1.5, 1.6 task.c, 1.15, 1.16 uuid.c, 1.11, 1.12
by Richard Allen Megginson
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 */
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/pwdstorage crypt_pwd.c, 1.6, 1.7
by Richard Allen Megginson
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>
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/passthru ptconfig.c, 1.8, 1.9
by Richard Allen Megginson
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 */
15 years, 5 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/pam_passthru pam_ptimpl.c, 1.11, 1.12
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/plugins/pam_passthru
Modified Files:
pam_ptimpl.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: pam_ptimpl.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/pam_passthru/pam_ptimpl.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- pam_ptimpl.c 18 Oct 2007 00:08:30 -0000 1.11
+++ pam_ptimpl.c 8 Oct 2008 17:29:02 -0000 1.12
@@ -177,7 +177,7 @@
* tell if this is actually the case.
*/
static int
-pam_conv_func(int num_msg, struct pam_message **msg, struct pam_response **resp, void *mydata)
+pam_conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *mydata)
{
int ii;
struct berval *creds;
15 years, 5 months