[PATCH] Some fixes from trying to build on OpenBSD

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Nov 18 13:55:33 UTC 2015


On Wed, Nov 18, 2015 at 11:12:49AM +0100, Volker Lendecke wrote:
> On Wed, Nov 18, 2015 at 11:04:07AM +0100, Ralph Boehme wrote:
> > On Wed, Nov 18, 2015 at 10:25:20AM +0100, Volker Lendecke wrote:
> > > On Tue, Nov 17, 2015 at 10:58:23PM +0100, Thomas Nagy wrote:
> > > > I did not see that it was removed. It looks alright!
> > > 
> > > Anybody willing to give me a review?
> > 
> > lgtm! Can you push?
> 
> Sure. Thanks!

Unfortunately the patch breaks on sn-devel. We need
memalign. On OpenBSD this does not exist, so libreplace
replaces it. The wscript test in libreplace only checks
whether memalign can link. Unfortunately in glibc memalign
comes from malloc.h.

Attached find a new patch.

Review appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From f55689d04086bd8ab3722fd9a24b4a21a997bfbf Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 13:52:02 +0200
Subject: [PATCH 1/7] libreplace: Only check malloc.h once

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/replace/wscript | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index 7bfe7ee..6f4f6bb 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -71,7 +71,7 @@ def configure(conf):
     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
-    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
+    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
     conf.CHECK_HEADERS('sys/atomic.h')
     conf.CHECK_HEADERS('libgen.h')
-- 
1.9.1


From bd0f618034b70dc3e26f5af3c0b9a705365384d8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 15:15:37 +0200
Subject: [PATCH 2/7] libreplace: Put the malloc.h check on a line of its own

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/replace/wscript | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index 6f4f6bb..d6cddf5 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -43,7 +43,9 @@ def configure(conf):
     conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
     conf.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h sys/file.h')
-    conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h malloc.h grp.h')
+    conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h')
+    conf.CHECK_HEADERS('malloc.h')
+    conf.CHECK_HEADERS('grp.h')
     conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
     conf.CHECK_HEADERS('stdarg.h vararg.h sys/mount.h mntent.h')
     conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
-- 
1.9.1


From f6193e8f13a40a6798713de98cfa3ee13f3f531f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 15:46:21 +0200
Subject: [PATCH 3/7] libreplace: Only check for malloc.h if needed

OpenBSD complains that malloc.h is deprecated on every gcc invocation.
That hides a lot of real warnings. malloc and friends nowadays are
typically defined in stdlib.h, only check there.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/replace/wscript | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index d6cddf5..093f930 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -44,7 +44,10 @@ def configure(conf):
     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
     conf.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h sys/file.h')
     conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h')
-    conf.CHECK_HEADERS('malloc.h')
+
+    if not conf.CHECK_DECLS('malloc', headers='stdlib.h'):
+        conf.CHECK_HEADERS('malloc.h')
+
     conf.CHECK_HEADERS('grp.h')
     conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
     conf.CHECK_HEADERS('stdarg.h vararg.h sys/mount.h mntent.h')
-- 
1.9.1


From 15dd71d11a57ec8c3453f54680a793a36c64e361 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 16 Nov 2015 16:11:48 +0100
Subject: [PATCH 4/7] idl: Avoid // style comments

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 librpc/idl/clusapi.idl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/librpc/idl/clusapi.idl b/librpc/idl/clusapi.idl
index 3440047..5cd815b 100644
--- a/librpc/idl/clusapi.idl
+++ b/librpc/idl/clusapi.idl
@@ -2046,7 +2046,7 @@ import "winreg.idl", "misc.idl";
 #endif
 
 	typedef struct {
-		uint32 dwObjectType;	  // really of type CLUSTER_OBJECT_TYPE_RPC
+		uint32 dwObjectType;	  /* really of type CLUSTER_OBJECT_TYPE_RPC */
 		hyper FilterFlags;
 	} NOTIFY_FILTER_AND_TYPE_RPC;
 
@@ -2068,9 +2068,9 @@ import "winreg.idl", "misc.idl";
 	/*****************/
 	/* Function 0x89 */
 
-	//
-	// Notify interface V2 functions
-	//
+	/*
+	 * Notify interface V2 functions
+	 */
 #if 0
 	HNOTIFY_RPC
 	clusapi_CreateNotifyV2(
-- 
1.9.1


From ee4bf7fac18f9a558c8fae50edbf2c69c2182d9a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 16 Nov 2015 16:23:10 +0100
Subject: [PATCH 5/7] idl: Some CC can't find indented #defines

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 librpc/idl/clusapi.idl | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/librpc/idl/clusapi.idl b/librpc/idl/clusapi.idl
index 5cd815b..8c4a227 100644
--- a/librpc/idl/clusapi.idl
+++ b/librpc/idl/clusapi.idl
@@ -28,15 +28,15 @@ import "winreg.idl", "misc.idl";
 	typedef [context_handle] void *HNETINTERFACE_RPC;
 	typedef [context_handle] void *HBATCH_PORT_RPC;
 #else
-	#define HCLUSTER_RPC policy_handle
-	#define HNODE_RPC policy_handle
-	#define HGROUP_RPC policy_handle
-	#define HRES_RPC policy_handle
-	#define HKEY_RPC policy_handle
-	#define HNOTIFY_RPC policy_handle
-	#define HNETWORK_RPC policy_handle
-	#define HNETINTERFACE_RPC policy_handle
-	#define HBATCH_PORT_RPC policy_handle
+#define HCLUSTER_RPC policy_handle
+#define HNODE_RPC policy_handle
+#define HGROUP_RPC policy_handle
+#define HRES_RPC policy_handle
+#define HKEY_RPC policy_handle
+#define HNOTIFY_RPC policy_handle
+#define HNETWORK_RPC policy_handle
+#define HNETINTERFACE_RPC policy_handle
+#define HBATCH_PORT_RPC policy_handle
 #endif
 
 	typedef struct {
-- 
1.9.1


From c5662cf2a699502fb91fa47f2ade15ec6c9b03e7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Nov 2015 13:13:57 +0100
Subject: [PATCH 6/7] lib: Fix memalign_array overflow protection

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/util/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/util/util.c b/lib/util/util.c
index d8a84da..069b380 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -773,7 +773,7 @@ void *malloc_array(size_t el_size, unsigned int count)
 
 void *memalign_array(size_t el_size, size_t align, unsigned int count)
 {
-	if (count*el_size >= MAX_MALLOC_SIZE) {
+	if (count >= MAX_MALLOC_SIZE/el_size) {
 		return NULL;
 	}
 
-- 
1.9.1


From 49f6e5f9eee8870f73bc89c49478c8610fd804b6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Nov 2015 13:03:46 +0100
Subject: [PATCH 7/7] lib: Check for memalign in malloc.h

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/replace/wscript | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index 093f930..37cbbb7 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -250,6 +250,10 @@ def configure(conf):
     conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
     conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
+
+    if conf.CONFIG_SET('HAVE_MEMALIGN'):
+        conf.CHECK_DECLS('memalign', headers='malloc.h')
+
     conf.CHECK_FUNCS('prctl dirname basename')
 
     # libbsd on some platforms provides strlcpy and strlcat
-- 
1.9.1



More information about the samba-technical mailing list