(ITS#6483) [PATCH] Properly use #elif
by delphij@FreeBSD.org
Full_Name: Xin LI
Version: -HEAD
OS: FreeBSD/amd64
URL: http://people.freebsd.org/~delphij/misc/openldap-elif.diff
Submission from: (NULL) (206.40.55.65)
OpenLDAP uses several #elif to test if a macro is being defined, which should be
spelled as #elif defined.
Here is a patch against CVS -HEAD.
Index: include/ac/regex.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/regex.h,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 regex.h
--- include/ac/regex.h 21 Jan 2009 23:40:18 -0000 1.20
+++ include/ac/regex.h 1 Mar 2010 20:12:52 -0000
@@ -28,7 +28,7 @@
*/
#error "No POSIX REGEX available."
-#elif HAVE_GNUREGEX_H
+#elif defined(HAVE_GNUREGEX_H)
/* system has GNU gnuregex.h */
# include <gnuregex.h>
#else
Index: include/ac/signal.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/signal.h,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 signal.h
--- include/ac/signal.h 21 Jan 2009 23:40:18 -0000 1.28
+++ include/ac/signal.h 1 Mar 2010 20:12:52 -0000
@@ -72,7 +72,7 @@ LDAP_LUTIL_F(lutil_sig_t) lutil_sigactio
#ifndef LDAP_SIGCHLD
#ifdef SIGCHLD
#define LDAP_SIGCHLD SIGCHLD
-#elif SIGCLD
+#elif defined(SIGCLD)
#define LDAP_SIGCHLD SIGCLD
#endif
#endif
Index: include/ac/socket.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/socket.h,v
retrieving revision 1.77
diff -u -p -u -p -r1.77 socket.h
--- include/ac/socket.h 23 Oct 2009 10:29:50 -0000 1.77
+++ include/ac/socket.h 1 Mar 2010 20:12:52 -0000
@@ -62,7 +62,7 @@
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
#include <winsock.h>
#endif
@@ -110,12 +110,12 @@
LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
-#elif MACOS
+#elif defined(MACOS)
# define tcp_close( s ) tcpclose( s )
# define tcp_read( s, buf, len ) tcpread( s, buf, len )
# define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
-#elif DOS
+#elif defined(DOS)
# ifdef PCNFS
# define tcp_close( s ) close( s )
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
Index: libraries/liblber/nt_err.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblber/nt_err.c,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 nt_err.c
--- libraries/liblber/nt_err.c 21 Jan 2009 23:40:19 -0000 1.18
+++ libraries/liblber/nt_err.c 1 Mar 2010 20:12:52 -0000
@@ -17,7 +17,7 @@
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
#include <winsock.h>
#endif /* HAVE_WINSOCK(2) */
Index: libraries/libldap/init.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/libldap/init.c,v
retrieving revision 1.123
diff -u -p -u -p -r1.123 init.c
--- libraries/libldap/init.c 15 Nov 2009 20:48:49 -0000 1.123
+++ libraries/libldap/init.c 1 Mar 2010 20:12:52 -0000
@@ -616,7 +616,7 @@ void ldap_int_initialize( struct ldapopt
return;
}
} /* The WinSock DLL is acceptable. Proceed. */
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
{ WSADATA wsaData;
if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
return;
Index: libraries/liblutil/detach.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblutil/detach.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 detach.c
--- libraries/liblutil/detach.c 21 Jan 2009 23:40:23 -0000 1.22
+++ libraries/liblutil/detach.c 1 Mar 2010 20:12:52 -0000
@@ -128,7 +128,7 @@ lutil_detach( int debug, int do_close )
#ifdef HAVE_SETSID
(void) setsid();
-#elif TIOCNOTTY
+#elif defined(TIOCNOTTY)
if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
(void) ioctl( sd, TIOCNOTTY, NULL );
(void) close( sd );
Index: libraries/liblutil/entropy.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblutil/entropy.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 entropy.c
--- libraries/liblutil/entropy.c 21 Jan 2009 23:40:23 -0000 1.32
+++ libraries/liblutil/entropy.c 1 Mar 2010 20:12:52 -0000
@@ -73,7 +73,7 @@ int lutil_entropy( unsigned char *buf, b
close(fd);
return nbytes > 0 ? -1 : 0;
}
-#elif PROV_RSA_FULL
+#elif defined(PROV_RSA_FULL)
{
/* Not used since _WIN32_WINNT not set... */
HCRYPTPROV hProv = 0;
[delphij@delta] ~/scratch/oo/ldap-src> cvs -qR diff -uNp > ~/openldap-elif.diff
[delphij@delta] ~/scratch/oo/ldap-src> cat ~/open
openldap-elif.diff openvpn.conf
[delphij@delta] ~/scratch/oo/ldap-src> cat ~/openldap-elif.diff
Index: include/ac/regex.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/regex.h,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 regex.h
--- include/ac/regex.h 21 Jan 2009 23:40:18 -0000 1.20
+++ include/ac/regex.h 1 Mar 2010 20:13:03 -0000
@@ -28,7 +28,7 @@
*/
#error "No POSIX REGEX available."
-#elif HAVE_GNUREGEX_H
+#elif defined(HAVE_GNUREGEX_H)
/* system has GNU gnuregex.h */
# include <gnuregex.h>
#else
Index: include/ac/signal.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/signal.h,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 signal.h
--- include/ac/signal.h 21 Jan 2009 23:40:18 -0000 1.28
+++ include/ac/signal.h 1 Mar 2010 20:13:03 -0000
@@ -72,7 +72,7 @@ LDAP_LUTIL_F(lutil_sig_t) lutil_sigactio
#ifndef LDAP_SIGCHLD
#ifdef SIGCHLD
#define LDAP_SIGCHLD SIGCHLD
-#elif SIGCLD
+#elif defined(SIGCLD)
#define LDAP_SIGCHLD SIGCLD
#endif
#endif
Index: include/ac/socket.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ac/socket.h,v
retrieving revision 1.77
diff -u -p -u -p -r1.77 socket.h
--- include/ac/socket.h 23 Oct 2009 10:29:50 -0000 1.77
+++ include/ac/socket.h 1 Mar 2010 20:13:03 -0000
@@ -62,7 +62,7 @@
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
#include <winsock.h>
#endif
@@ -110,12 +110,12 @@
LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
-#elif MACOS
+#elif defined(MACOS)
# define tcp_close( s ) tcpclose( s )
# define tcp_read( s, buf, len ) tcpread( s, buf, len )
# define tcp_write( s, buf, len ) tcpwrite( s, buf, len )
-#elif DOS
+#elif defined(DOS)
# ifdef PCNFS
# define tcp_close( s ) close( s )
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
Index: libraries/liblber/nt_err.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblber/nt_err.c,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 nt_err.c
--- libraries/liblber/nt_err.c 21 Jan 2009 23:40:19 -0000 1.18
+++ libraries/liblber/nt_err.c 1 Mar 2010 20:13:03 -0000
@@ -17,7 +17,7 @@
#ifdef HAVE_WINSOCK2
#include <winsock2.h>
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
#include <winsock.h>
#endif /* HAVE_WINSOCK(2) */
Index: libraries/libldap/init.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/libldap/init.c,v
retrieving revision 1.123
diff -u -p -u -p -r1.123 init.c
--- libraries/libldap/init.c 15 Nov 2009 20:48:49 -0000 1.123
+++ libraries/libldap/init.c 1 Mar 2010 20:13:03 -0000
@@ -616,7 +616,7 @@ void ldap_int_initialize( struct ldapopt
return;
}
} /* The WinSock DLL is acceptable. Proceed. */
-#elif HAVE_WINSOCK
+#elif defined(HAVE_WINSOCK)
{ WSADATA wsaData;
if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
return;
Index: libraries/liblutil/detach.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblutil/detach.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 detach.c
--- libraries/liblutil/detach.c 21 Jan 2009 23:40:23 -0000 1.22
+++ libraries/liblutil/detach.c 1 Mar 2010 20:13:03 -0000
@@ -128,7 +128,7 @@ lutil_detach( int debug, int do_close )
#ifdef HAVE_SETSID
(void) setsid();
-#elif TIOCNOTTY
+#elif defined(TIOCNOTTY)
if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
(void) ioctl( sd, TIOCNOTTY, NULL );
(void) close( sd );
Index: libraries/liblutil/entropy.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/libraries/liblutil/entropy.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 entropy.c
--- libraries/liblutil/entropy.c 21 Jan 2009 23:40:23 -0000 1.32
+++ libraries/liblutil/entropy.c 1 Mar 2010 20:13:03 -0000
@@ -73,7 +73,7 @@ int lutil_entropy( unsigned char *buf, b
close(fd);
return nbytes > 0 ? -1 : 0;
}
-#elif PROV_RSA_FULL
+#elif defined(PROV_RSA_FULL)
{
/* Not used since _WIN32_WINNT not set... */
HCRYPTPROV hProv = 0;
13 years
(ITS#6482) slapcat doesn't continue with -c after the first corrupted database entry
by sysadmin@htl-leonding.ac.at
Full_Name: Himmelbauer
Version: 2.4.19
OS: Gentoo Linux
URL: ftp://ftp.openldap.org/incoming/himmelbauer-100301.patch
Submission from: (NULL) (92.248.100.200)
Was not able to retrieve database entries from a corrupted LDAP database using
slapcat (openldap 2.4.19) with option -c. It aborts after the first corrupted
entry with
<= entry_decode: slap_str2undef_ad(object�!p): AttributeDescription
contains inappropriate characters
# no data for entry id=xxxxxxxx
and doesn't continue with the next valid entry as I would have expected.
A damaged database is not good, but as slapcat is described as the tool to
recover the non-corrupted data in various forums, it would be good when it
really continues on errors. Other ldap-related tools like ldapsearch ignore the
damaged data, so it is really annoying, when you want to recover your data and
don't even get all the readable entries.
The patch corrects the handling of damaged entries by slapcat when -c is used,
so that the output is continued with the next non-damaged entry. When -c is not
used slapcat stops after the first corrupted entry (as expected).
The patch works for me, but I know that it is not really correct, because when
there would be no non-damaged entry left it would either cause a endless loop or
some crashes.
So a modification would be needed to stop the loop when the last database entry
was processed, but I didn't know how to access that id.
13 years