shall libreplace become a public library (Was: Re: [SCM] Samba Shared Repository - branch master updated)
Christian Ambach
ambi at samba.org
Thu Dec 5 02:45:01 MST 2013
Am 29.11.13 23:16, schrieb Jelmer Vernooij:
>> Subject: [PATCH 01/10] s3:utils remove orphaned code
> Reviewed-By: Jelmer Vernooij <jelmer at samba.org>
>> Subject: [PATCH 02/10] lib/replace remove orphaned code
> Reviewed-By: Jelmer Vernooij <jelmer at samba.org>
Thanks you for the reviews. I have pushed those two and attached a set
of revised patches that still need reviews. So please have another look.
> It might be intentional that the testsuite only uses the external
> API, and that could be a reason why these are not including private.h
> at the moment. Perhaps Rusty can comment on that.
>
>> From 832a335f79bb20b15eb263e516d341846b5348b7 Mon Sep 17 00:00:00 2001
>> From: Christian Ambach <ambi at samba.org>
>> Date: Fri, 22 Nov 2013 05:19:16 +0100
>> Subject: [PATCH 10/10] lib/ntdb optimize includes in ntdb tools
>>
>> use the private header (which will use libreplace or system headers) instead of direct includes of system includes
>
> Reviewed-By: Jelmer Vernooij <jelmer at samba.org>
>
> ... but it'd be great if Rusty could have a look too.
I have included all ntdb related patches again for a review by Rusty.
Cheers,
Christian
-------------- next part --------------
>From f28c643e9723e4febd37016b93d76932ac4fad26 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:12:05 +0100
Subject: [PATCH 1/8] s3:lib/asys modify included headers
use the headers from libreplace, not the system ones
Signed-off-by: Christian Ambach <ambi at samba.org>
---
source3/lib/asys/asys.h | 6 ++----
source3/lib/asys/wscript_build | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/source3/lib/asys/asys.h b/source3/lib/asys/asys.h
index 73f1051..468ac3f 100644
--- a/source3/lib/asys/asys.h
+++ b/source3/lib/asys/asys.h
@@ -19,10 +19,8 @@
#ifndef __ASYS_H__
#define __ASYS_H__
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include "../lib/replace/replace.h"
+#include "../lib/replace/system/filesys.h"
/**
* @defgroup asys The async syscall library
diff --git a/source3/lib/asys/wscript_build b/source3/lib/asys/wscript_build
index 15de977..dca56c7 100644
--- a/source3/lib/asys/wscript_build
+++ b/source3/lib/asys/wscript_build
@@ -2,7 +2,7 @@
bld.SAMBA3_SUBSYSTEM('LIBASYS',
source='asys.c',
- deps='PTHREADPOOL')
+ deps='PTHREADPOOL replace')
bld.SAMBA3_BINARY('asystest',
source='tests.c',
--
1.8.1.2
>From a0406d7e6a0c2d2aea3c51ff0d470a4015694e98 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:13:56 +0100
Subject: [PATCH 2/8] s3:pam_smbpass change includes
use the ones from libreplace instead of system ones
Signed-off-by: Christian Ambach <ambi at samba.org>
---
source3/pam_smbpass/general.h | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/source3/pam_smbpass/general.h b/source3/pam_smbpass/general.h
index 6e13f8d..c3e4b8b 100644
--- a/source3/pam_smbpass/general.h
+++ b/source3/pam_smbpass/general.h
@@ -21,13 +21,10 @@
#define PAM_AUTHTOK_RECOVER_ERR PAM_AUTHTOK_RECOVERY_ERR
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/wait.h"
+#include "system/syslog.h"
/*
* here is the string to inform the user that the new passwords they
--
1.8.1.2
>From cbe8e372e6de9a1cd9830c37f680e6c60c1cb3f2 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:13:17 +0100
Subject: [PATCH 3/8] s3:vfs_btrfs change includes
use the ones from libreplace instead of system ones
Signed-off-by: Christian Ambach <ambi at samba.org>
---
source3/modules/vfs_btrfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index c6e90fd..2254fa2 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -20,10 +20,9 @@
#include <linux/ioctl.h>
#include <linux/fs.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
+#include "system/filesys.h"
#include "includes.h"
#include "smbd/smbd.h"
#include "librpc/gen_ndr/smbXsrv.h"
--
1.8.1.2
>From 7d1e4361485f85d3e3c83e6d1340a30422862a02 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:15:13 +0100
Subject: [PATCH 4/8] lib/socket_wrapper fix compilation when libreplace is not
around
Signed-off-by: Christian Ambach <ambi at samba.org>
---
lib/socket_wrapper/socket_wrapper.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 3c9d0f1..a8369ad 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -56,7 +56,9 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
+#endif
#include <errno.h>
#include <sys/un.h>
#include <netinet/in.h>
@@ -67,9 +69,27 @@
#include <string.h>
#include <stdio.h>
#include <stdint.h>
+#include <arpa/inet.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
+
+/**
+ * zero a structure
+ */
+#ifndef ZERO_STRUCT
+#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+#endif
#endif /* HAVE_LIBREPLACE */
+#include "socket_wrapper.h"
+
#ifndef _PUBLIC_
#define _PUBLIC_
#endif
--
1.8.1.2
>From a5183d0c75ee7a1cb889b5980e4d361b19be0bdb Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:15:59 +0100
Subject: [PATCH 5/8] lib/ntdb fix compilation when libreplace is not around
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-By: Jelmer Vernooij <jelmer at samba.org>
---
lib/ntdb/ntdb.c | 1 -
lib/ntdb/ntdb.h | 10 ++++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/ntdb/ntdb.c b/lib/ntdb/ntdb.c
index 5d56b33..51fbbca 100644
--- a/lib/ntdb/ntdb.c
+++ b/lib/ntdb/ntdb.c
@@ -17,7 +17,6 @@
*/
#include "private.h"
#ifndef HAVE_LIBREPLACE
-#include <ccan/asprintf/asprintf.h>
#include <stdarg.h>
#endif
diff --git a/lib/ntdb/ntdb.h b/lib/ntdb/ntdb.h
index df3a9dd..a3a627f 100644
--- a/lib/ntdb/ntdb.h
+++ b/lib/ntdb/ntdb.h
@@ -31,10 +31,20 @@ extern "C" {
#ifdef HAVE_LIBREPLACE
#include <replace.h>
+#include <system/filesys.h>
#else
#if HAVE_FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
+
+#ifndef _PUBLIC_
+#ifdef HAVE_VISIBILITY_ATTR
+#define _PUBLIC_ __attribute__((visibility("default")))
+#else
+#define _PUBLIC_
+#endif
+#endif
+
/* For mode_t */
#include <sys/types.h>
/* For O_* flags. */
--
1.8.1.2
>From 9ffe91b884b2fb615fe27d077d69a668eb05e7d3 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:17:38 +0100
Subject: [PATCH 6/8] lib/ntdb correct includes in private header
include all necessary headers when libreplace is not around
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-By: Jelmer Vernooij <jelmer at samba.org>
---
lib/ntdb/private.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/ntdb/private.h b/lib/ntdb/private.h
index 5efd2e0..2492537 100644
--- a/lib/ntdb/private.h
+++ b/lib/ntdb/private.h
@@ -35,6 +35,7 @@
#include "system/select.h"
#include "system/wait.h"
#else
+#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -47,6 +48,10 @@
#include <stdio.h>
#include <utime.h>
#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <time.h>
#endif
#include <assert.h>
--
1.8.1.2
>From 6ad19834e2603a373c9b10afee9bbabc0fa9378e Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:18:36 +0100
Subject: [PATCH 7/8] lib/ntdb optimize includes in ntdb tests
use the private header (which will use libreplace or system headers)
instead of direct includes of system includes
Signed-off-by: Christian Ambach <ambi at samba.org>
---
lib/ntdb/test/api-12-store.c | 4 +---
lib/ntdb/test/api-13-delete.c | 3 ---
lib/ntdb/test/api-14-exists.c | 4 +---
lib/ntdb/test/api-16-wipe_all.c | 4 +---
lib/ntdb/test/api-20-alloc-attr.c | 4 +---
lib/ntdb/test/api-21-parse_record.c | 4 +---
lib/ntdb/test/api-55-transaction.c | 3 ---
lib/ntdb/test/api-60-noop-transaction.c | 3 ---
lib/ntdb/test/api-80-tdb_fd.c | 4 +---
lib/ntdb/test/api-81-seqnum.c | 4 +---
lib/ntdb/test/api-82-lockattr.c | 3 ---
lib/ntdb/test/api-83-openhook.c | 8 +-------
lib/ntdb/test/api-91-get-stats.c | 6 +-----
lib/ntdb/test/api-92-get-set-readonly.c | 4 +---
lib/ntdb/test/api-93-repack.c | 4 +---
lib/ntdb/test/api-94-expand-during-parse.c | 3 ---
lib/ntdb/test/api-95-read-only-during-parse.c | 4 +---
lib/ntdb/test/api-add-remove-flags.c | 3 ---
lib/ntdb/test/api-check-callback.c | 4 +---
lib/ntdb/test/api-firstkey-nextkey.c | 5 +----
lib/ntdb/test/api-fork-test.c | 8 +-------
lib/ntdb/test/api-locktimeout.c | 7 +------
lib/ntdb/test/api-missing-entries.c | 4 +---
lib/ntdb/test/api-open-multiple-times.c | 3 ---
lib/ntdb/test/api-record-expand.c | 5 +----
lib/ntdb/test/api-simple-delete.c | 4 +---
lib/ntdb/test/api-summary.c | 5 +----
27 files changed, 20 insertions(+), 97 deletions(-)
diff --git a/lib/ntdb/test/api-12-store.c b/lib/ntdb/test/api-12-store.c
index 45274e0..532a8ee 100644
--- a/lib/ntdb/test/api-12-store.c
+++ b/lib/ntdb/test/api-12-store.c
@@ -1,10 +1,8 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
#include <ccan/hash/hash.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-13-delete.c b/lib/ntdb/test/api-13-delete.c
index cded8fd..730ade5 100644
--- a/lib/ntdb/test/api-13-delete.c
+++ b/lib/ntdb/test/api-13-delete.c
@@ -1,8 +1,5 @@
#include "private.h" // For NTDB_TOPLEVEL_HASH_BITS
#include <ccan/hash/hash.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "ntdb.h"
#include "tap-interface.h"
#include "logging.h"
diff --git a/lib/ntdb/test/api-14-exists.c b/lib/ntdb/test/api-14-exists.c
index abaaae0..c40d901 100644
--- a/lib/ntdb/test/api-14-exists.c
+++ b/lib/ntdb/test/api-14-exists.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
static bool test_records(struct ntdb_context *ntdb)
diff --git a/lib/ntdb/test/api-16-wipe_all.c b/lib/ntdb/test/api-16-wipe_all.c
index 6a60752..4eea151 100644
--- a/lib/ntdb/test/api-16-wipe_all.c
+++ b/lib/ntdb/test/api-16-wipe_all.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
static bool add_records(struct ntdb_context *ntdb)
diff --git a/lib/ntdb/test/api-20-alloc-attr.c b/lib/ntdb/test/api-20-alloc-attr.c
index e4ec89a..3df5003 100644
--- a/lib/ntdb/test/api-20-alloc-attr.c
+++ b/lib/ntdb/test/api-20-alloc-attr.c
@@ -1,10 +1,8 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
#include <ccan/hash/hash.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <assert.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-21-parse_record.c b/lib/ntdb/test/api-21-parse_record.c
index 975bbfa..5af9abe 100644
--- a/lib/ntdb/test/api-21-parse_record.c
+++ b/lib/ntdb/test/api-21-parse_record.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
static enum NTDB_ERROR parse(NTDB_DATA key, NTDB_DATA data, NTDB_DATA *expected)
diff --git a/lib/ntdb/test/api-55-transaction.c b/lib/ntdb/test/api-55-transaction.c
index 01a1dce..3d3e539 100644
--- a/lib/ntdb/test/api-55-transaction.c
+++ b/lib/ntdb/test/api-55-transaction.c
@@ -1,9 +1,6 @@
#include "private.h" // struct ntdb_context
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-60-noop-transaction.c b/lib/ntdb/test/api-60-noop-transaction.c
index a429e67..5e56dbc 100644
--- a/lib/ntdb/test/api-60-noop-transaction.c
+++ b/lib/ntdb/test/api-60-noop-transaction.c
@@ -1,9 +1,6 @@
#include "private.h" // struct ntdb_context
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-80-tdb_fd.c b/lib/ntdb/test/api-80-tdb_fd.c
index 81b7284..ca520a9 100644
--- a/lib/ntdb/test/api-80-tdb_fd.c
+++ b/lib/ntdb/test/api-80-tdb_fd.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
diff --git a/lib/ntdb/test/api-81-seqnum.c b/lib/ntdb/test/api-81-seqnum.c
index 04f49cd..45963ff 100644
--- a/lib/ntdb/test/api-81-seqnum.c
+++ b/lib/ntdb/test/api-81-seqnum.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-82-lockattr.c b/lib/ntdb/test/api-82-lockattr.c
index 4fbe1d2..f71600c 100644
--- a/lib/ntdb/test/api-82-lockattr.c
+++ b/lib/ntdb/test/api-82-lockattr.c
@@ -1,9 +1,6 @@
#include "private.h" // for ntdb_fcntl_unlock
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <errno.h>
#include "logging.h"
diff --git a/lib/ntdb/test/api-83-openhook.c b/lib/ntdb/test/api-83-openhook.c
index 3816eef..d2930ac 100644
--- a/lib/ntdb/test/api-83-openhook.c
+++ b/lib/ntdb/test/api-83-openhook.c
@@ -1,13 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdarg.h>
-#include <unistd.h>
#include "external-agent.h"
#include "logging.h"
diff --git a/lib/ntdb/test/api-91-get-stats.c b/lib/ntdb/test/api-91-get-stats.c
index 1ed36f0..1041cba 100644
--- a/lib/ntdb/test/api-91-get-stats.c
+++ b/lib/ntdb/test/api-91-get-stats.c
@@ -1,11 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stddef.h>
#include "logging.h"
int main(int argc, char *argv[])
diff --git a/lib/ntdb/test/api-92-get-set-readonly.c b/lib/ntdb/test/api-92-get-set-readonly.c
index 81eadff..c557f34 100644
--- a/lib/ntdb/test/api-92-get-set-readonly.c
+++ b/lib/ntdb/test/api-92-get-set-readonly.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
diff --git a/lib/ntdb/test/api-93-repack.c b/lib/ntdb/test/api-93-repack.c
index 4a30c57..0fade08 100644
--- a/lib/ntdb/test/api-93-repack.c
+++ b/lib/ntdb/test/api-93-repack.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
#define NUM_TESTS 1000
diff --git a/lib/ntdb/test/api-94-expand-during-parse.c b/lib/ntdb/test/api-94-expand-during-parse.c
index 4963e47..3aca88b 100644
--- a/lib/ntdb/test/api-94-expand-during-parse.c
+++ b/lib/ntdb/test/api-94-expand-during-parse.c
@@ -2,9 +2,6 @@
#include "config.h"
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
#include "../private.h" /* To establish size, esp. for NTDB_INTERNAL dbs */
diff --git a/lib/ntdb/test/api-95-read-only-during-parse.c b/lib/ntdb/test/api-95-read-only-during-parse.c
index 8252b81..53adbc3 100644
--- a/lib/ntdb/test/api-95-read-only-during-parse.c
+++ b/lib/ntdb/test/api-95-read-only-during-parse.c
@@ -1,10 +1,8 @@
/* Make sure write operations fail during ntdb_parse(). */
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
static struct ntdb_context *ntdb;
diff --git a/lib/ntdb/test/api-add-remove-flags.c b/lib/ntdb/test/api-add-remove-flags.c
index c5a3f42..c16ceeb 100644
--- a/lib/ntdb/test/api-add-remove-flags.c
+++ b/lib/ntdb/test/api-add-remove-flags.c
@@ -1,9 +1,6 @@
#include "private.h" // for ntdb_context
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
diff --git a/lib/ntdb/test/api-check-callback.c b/lib/ntdb/test/api-check-callback.c
index b5ca8a0..20c88e7 100644
--- a/lib/ntdb/test/api-check-callback.c
+++ b/lib/ntdb/test/api-check-callback.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
#define NUM_RECORDS 1000
diff --git a/lib/ntdb/test/api-firstkey-nextkey.c b/lib/ntdb/test/api-firstkey-nextkey.c
index 5e83e6b..179cf76 100644
--- a/lib/ntdb/test/api-firstkey-nextkey.c
+++ b/lib/ntdb/test/api-firstkey-nextkey.c
@@ -1,10 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
#include "logging.h"
#define NUM_RECORDS 1000
diff --git a/lib/ntdb/test/api-fork-test.c b/lib/ntdb/test/api-fork-test.c
index 6298a4a..4b114d6 100644
--- a/lib/ntdb/test/api-fork-test.c
+++ b/lib/ntdb/test/api-fork-test.c
@@ -12,14 +12,8 @@
*/
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
#include "logging.h"
static bool am_child = false;
diff --git a/lib/ntdb/test/api-locktimeout.c b/lib/ntdb/test/api-locktimeout.c
index 5e24d58..4c0fda2 100644
--- a/lib/ntdb/test/api-locktimeout.c
+++ b/lib/ntdb/test/api-locktimeout.c
@@ -1,13 +1,8 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include "system/wait.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <fcntl.h>
#include <limits.h>
-#include <errno.h>
#include "logging.h"
#include "external-agent.h"
diff --git a/lib/ntdb/test/api-missing-entries.c b/lib/ntdb/test/api-missing-entries.c
index d9a1fd9..2a00f1b3 100644
--- a/lib/ntdb/test/api-missing-entries.c
+++ b/lib/ntdb/test/api-missing-entries.c
@@ -1,11 +1,9 @@
/* Another test revealed that we lost an entry. This reproduces it. */
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include <ccan/hash/hash.h>
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
#define NUM_RECORDS 1189
diff --git a/lib/ntdb/test/api-open-multiple-times.c b/lib/ntdb/test/api-open-multiple-times.c
index 8663b8a..6b97bc9 100644
--- a/lib/ntdb/test/api-open-multiple-times.c
+++ b/lib/ntdb/test/api-open-multiple-times.c
@@ -1,9 +1,6 @@
#include "config.h"
#include "ntdb.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <stdlib.h>
#include "logging.h"
#include "../private.h"
diff --git a/lib/ntdb/test/api-record-expand.c b/lib/ntdb/test/api-record-expand.c
index 8786fc7..74fb27f 100644
--- a/lib/ntdb/test/api-record-expand.c
+++ b/lib/ntdb/test/api-record-expand.c
@@ -1,10 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
#include "logging.h"
#define MAX_SIZE 10000
diff --git a/lib/ntdb/test/api-simple-delete.c b/lib/ntdb/test/api-simple-delete.c
index dedc433..e8baf4c 100644
--- a/lib/ntdb/test/api-simple-delete.c
+++ b/lib/ntdb/test/api-simple-delete.c
@@ -1,9 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
diff --git a/lib/ntdb/test/api-summary.c b/lib/ntdb/test/api-summary.c
index df5d092..af1b595 100644
--- a/lib/ntdb/test/api-summary.c
+++ b/lib/ntdb/test/api-summary.c
@@ -1,10 +1,7 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include "tap-interface.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
#include "logging.h"
int main(int argc, char *argv[])
--
1.8.1.2
>From feaa5e44bdfe95ebeb9e0f1025f7c65e22fafa56 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
Date: Fri, 22 Nov 2013 05:19:16 +0100
Subject: [PATCH 8/8] lib/ntdb optimize includes in ntdb tools
use the private header (which will use libreplace or system headers)
instead of direct includes of system includes
Signed-off-by: Christian Ambach <ambi at samba.org>
---
lib/ntdb/tools/growtdb-bench.c | 3 ---
lib/ntdb/tools/ntdbbackup.c | 2 +-
lib/ntdb/tools/ntdbdump.c | 14 +-------------
lib/ntdb/tools/ntdbrestore.c | 11 +----------
lib/ntdb/tools/ntdbtool.c | 18 +-----------------
lib/ntdb/tools/ntdbtorture.c | 16 +---------------
lib/ntdb/tools/speed.c | 2 --
7 files changed, 5 insertions(+), 61 deletions(-)
diff --git a/lib/ntdb/tools/growtdb-bench.c b/lib/ntdb/tools/growtdb-bench.c
index aa5a406..28c1de8 100644
--- a/lib/ntdb/tools/growtdb-bench.c
+++ b/lib/ntdb/tools/growtdb-bench.c
@@ -4,9 +4,6 @@
#include <stdio.h>
#include <unistd.h>
#include <ccan/err/err.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
static void logfn(struct ntdb_context *ntdb,
enum ntdb_log_level level,
diff --git a/lib/ntdb/tools/ntdbbackup.c b/lib/ntdb/tools/ntdbbackup.c
index a76f184..c632f0e 100644
--- a/lib/ntdb/tools/ntdbbackup.c
+++ b/lib/ntdb/tools/ntdbbackup.c
@@ -42,7 +42,7 @@
#include "config.h"
#include "ntdb.h"
-#include "system/filesys.h"
+#include "private.h"
#ifdef HAVE_GETOPT_H
#include <getopt.h>
diff --git a/lib/ntdb/tools/ntdbdump.c b/lib/ntdb/tools/ntdbdump.c
index 1b1c59e..fc83796 100644
--- a/lib/ntdb/tools/ntdbdump.c
+++ b/lib/ntdb/tools/ntdbdump.c
@@ -18,19 +18,7 @@
*/
#include "config.h"
#include "ntdb.h"
-#ifdef HAVE_LIBREPLACE
-#include <replace.h>
-#include <system/filesys.h>
-#include <system/locale.h>
-#else
-#include <ctype.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#endif
+#include "private.h"
static void print_data(NTDB_DATA d)
{
diff --git a/lib/ntdb/tools/ntdbrestore.c b/lib/ntdb/tools/ntdbrestore.c
index 1df9322..695af79 100644
--- a/lib/ntdb/tools/ntdbrestore.c
+++ b/lib/ntdb/tools/ntdbrestore.c
@@ -20,17 +20,8 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include <assert.h>
-#ifdef HAVE_LIBREPLACE
-#include <replace.h>
-#include <system/filesys.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#endif
static int read_linehead(FILE *f)
{
diff --git a/lib/ntdb/tools/ntdbtool.c b/lib/ntdb/tools/ntdbtool.c
index 7c1ef7d..144cd92 100644
--- a/lib/ntdb/tools/ntdbtool.c
+++ b/lib/ntdb/tools/ntdbtool.c
@@ -22,23 +22,7 @@
#include "config.h"
#include "ntdb.h"
-#ifdef HAVE_LIBREPLACE
-#include <replace.h>
-#include <system/filesys.h>
-#include <system/time.h>
-#include <system/locale.h>
-#else
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdarg.h>
-#endif
+#include "private.h"
static int do_command(void);
const char *cmdname;
diff --git a/lib/ntdb/tools/ntdbtorture.c b/lib/ntdb/tools/ntdbtorture.c
index 7ddb5c3..9fd25ca 100644
--- a/lib/ntdb/tools/ntdbtorture.c
+++ b/lib/ntdb/tools/ntdbtorture.c
@@ -4,22 +4,8 @@
#include "config.h"
#include "ntdb.h"
+#include "private.h"
#include <ccan/err/err.h>
-#ifdef HAVE_LIBREPLACE
-#include <replace.h>
-#else
-#include <stdlib.h>
-#include <getopt.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/wait.h>
-#endif
//#define REOPEN_PROB 30
#define DELETE_PROB 8
diff --git a/lib/ntdb/tools/speed.c b/lib/ntdb/tools/speed.c
index 8928d8c..a829321 100644
--- a/lib/ntdb/tools/speed.c
+++ b/lib/ntdb/tools/speed.c
@@ -1,8 +1,6 @@
/* Simple speed test for NTDB */
#include <ccan/err/err.h>
#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <sys/time.h>
#include <fcntl.h>
--
1.8.1.2
More information about the samba-technical
mailing list