All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Various build fixes for building bluez with musl libc
@ 2014-03-14  9:59 Natanael Copa
  2014-03-14  9:59 ` [PATCH 1/3] shared: include endian.h for be32toh, htobe32 and htobe64 functions Natanael Copa
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Natanael Copa @ 2014-03-14  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Natanael Copa

The following fixes are needed to make bluez build on Alpine Linuz with
musl libc.

This is kind of a rebase of the previously posted patches:
http://www.spinics.net/lists/linux-bluetooth/msg43070.html

Changes since then are:
- mention Alpine Linux in commit message
- rebase to current git
- added fix for proper header include for be32toh, htobe32 and htobe64

Please note that "unit: prevent unintended use of glibc's error(3)"
fixes a bug in the unit test that affects glibc too. I suppose that if
you add a testcase that triggers any error logging from sdpd-request.c
it will likely segfault instead of gracfully hande the error condition.
(it only affects the unit test though)

Natanael Copa (3):
  shared: include endian.h for be32toh, htobe32 and htobe64 functions
  unit: prevent unintended use of glibc's error(3)
  bnep: avoid use of caddr_t

 Makefile.am             | 1 +
 profiles/network/bnep.c | 4 ++--
 src/shared/btsnoop.c    | 1 +
 unit/test-sdp.c         | 9 +++------
 4 files changed, 7 insertions(+), 8 deletions(-)

-- 
1.9.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] shared: include endian.h for be32toh, htobe32 and htobe64 functions
  2014-03-14  9:59 [PATCH 0/3] Various build fixes for building bluez with musl libc Natanael Copa
@ 2014-03-14  9:59 ` Natanael Copa
  2014-03-14  9:59 ` [PATCH 2/3] unit: prevent unintended use of glibc's error(3) Natanael Copa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Natanael Copa @ 2014-03-14  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Natanael Copa

The man page says that #include <endian.h> is needed for those.

This fixes the following compile error when building with musl libc on
Alpine Linux:

src/shared/btsnoop.o: In function `btsnoop_write':
.../src/bluez/src/shared/btsnoop.c:208: undefined reference to `htobe32'
.../src/bluez/src/shared/btsnoop.c:209: undefined reference to `htobe32'
.../src/bluez/src/shared/btsnoop.c:210: undefined reference to `htobe32'
.../src/bluez/src/shared/btsnoop.c:211: undefined reference to `htobe32'
.../src/bluez/src/shared/btsnoop.c:212: undefined reference to `htobe64'
src/shared/btsnoop.o: In function `btsnoop_open':
.../src/bluez/src/shared/btsnoop.c:100: undefined reference to `be32toh'
.../src/bluez/src/shared/btsnoop.c:103: undefined reference to `be32toh'
src/shared/btsnoop.o: In function `btsnoop_create':
.../src/bluez/src/shared/btsnoop.c:151: undefined reference to `htobe32'
.../src/bluez/src/shared/btsnoop.c:152: undefined reference to `htobe32'
src/shared/btsnoop.o: In function `pklg_read_hci':
.../src/bluez/src/shared/btsnoop.c:336: undefined reference to `be32toh'
.../src/bluez/src/shared/btsnoop.c:338: undefined reference to `be64toh'
src/shared/btsnoop.o: In function `btsnoop_read_hci':
.../src/bluez/src/shared/btsnoop.c:416: undefined reference to `be32toh'
.../src/bluez/src/shared/btsnoop.c:417: undefined reference to `be32toh'
.../src/bluez/src/shared/btsnoop.c:419: undefined reference to `be64toh'
---

This was introduced with 83afd2d1a (shared: Use be32toh, htobe32 and
htobe64 functions)

 src/shared/btsnoop.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c
index d2b3b4b..17a872c 100644
--- a/src/shared/btsnoop.c
+++ b/src/shared/btsnoop.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#include <endian.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] unit: prevent unintended use of glibc's error(3)
  2014-03-14  9:59 [PATCH 0/3] Various build fixes for building bluez with musl libc Natanael Copa
  2014-03-14  9:59 ` [PATCH 1/3] shared: include endian.h for be32toh, htobe32 and htobe64 functions Natanael Copa
@ 2014-03-14  9:59 ` Natanael Copa
  2014-03-14  9:59 ` [PATCH 3/3] bnep: avoid use of caddr_t Natanael Copa
  2014-03-14 11:07 ` [PATCH 0/3] Various build fixes for building bluez with musl libc Johan Hedberg
  3 siblings, 0 replies; 6+ messages in thread
From: Natanael Copa @ 2014-03-14  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Natanael Copa

When building the test-sdp we don't want src/sdpd-request.c end up
using the incompatible GNU libc's error(3) instead of the intended
src/log.c's error().

This also fixes the following compile error on Alpine Linux with musl
libc which does not implement the error(3) GNU extension:

src/sdpd-request.o: In function `extract_des':
/home/ncopa/src/bluez/src/sdpd-request.c:126: undefined reference to `error'
src/sdpd-request.o: In function `process_request':
/home/ncopa/src/bluez/src/sdpd-request.c:1022: undefined reference to `error'
/home/ncopa/src/bluez/src/sdpd-request.c:1045: undefined reference to `error'
---
 Makefile.am     | 1 +
 unit/test-sdp.c | 9 +++------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index fb11230..700b956 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -265,6 +265,7 @@ unit_tests += unit/test-sdp
 unit_test_sdp_SOURCES = unit/test-sdp.c \
 				src/shared/util.h src/shared/util.c \
 				src/sdpd.h src/sdpd-database.c \
+				src/log.h src/log.c \
 				src/sdpd-service.c src/sdpd-request.c
 unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
 
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index 9b82343..853576d 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -128,12 +128,6 @@ static void sdp_debug(const char *str, void *user_data)
 	g_print("%s%s\n", prefix, str);
 }
 
-void btd_debug(const char *format, ...);
-
-void btd_debug(const char *format, ...)
-{
-}
-
 static void context_quit(struct context *context)
 {
 	g_main_loop_quit(context->main_loop);
@@ -797,6 +791,9 @@ int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
 
+	if (g_test_verbose())
+		__btd_log_init("*", 0);
+
 	/*
 	 * Service Search Request
 	 *
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] bnep: avoid use of caddr_t
  2014-03-14  9:59 [PATCH 0/3] Various build fixes for building bluez with musl libc Natanael Copa
  2014-03-14  9:59 ` [PATCH 1/3] shared: include endian.h for be32toh, htobe32 and htobe64 functions Natanael Copa
  2014-03-14  9:59 ` [PATCH 2/3] unit: prevent unintended use of glibc's error(3) Natanael Copa
@ 2014-03-14  9:59 ` Natanael Copa
  2014-03-14 11:07 ` [PATCH 0/3] Various build fixes for building bluez with musl libc Johan Hedberg
  3 siblings, 0 replies; 6+ messages in thread
From: Natanael Copa @ 2014-03-14  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Natanael Copa

caddr_t is legacy BSD and should be avoided.

This fixes the following compile error on Alpine Linux with musl libc:
profiles/network/bnep.c: In function 'bnep_if_up':
profiles/network/bnep.c:205:33: error: 'caddr_t' undeclared (first use in this function)
  err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);
---

For more details please see:
http://stackoverflow.com/questions/6381526/what-is-the-significance-of-caddr-t-and-when-is-it-used

 profiles/network/bnep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index ece979f..b93027a 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -204,7 +204,7 @@ static int bnep_if_up(const char *devname)
 	ifr.ifr_flags |= IFF_UP;
 	ifr.ifr_flags |= IFF_MULTICAST;
 
-	err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);
+	err = ioctl(sk, SIOCSIFFLAGS, (void *) &ifr);
 
 	close(sk);
 
@@ -229,7 +229,7 @@ static int bnep_if_down(const char *devname)
 	ifr.ifr_flags &= ~IFF_UP;
 
 	/* Bring down the interface */
-	err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);
+	err = ioctl(sk, SIOCSIFFLAGS, (void *) &ifr);
 
 	close(sk);
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Various build fixes for building bluez with musl libc
  2014-03-14  9:59 [PATCH 0/3] Various build fixes for building bluez with musl libc Natanael Copa
                   ` (2 preceding siblings ...)
  2014-03-14  9:59 ` [PATCH 3/3] bnep: avoid use of caddr_t Natanael Copa
@ 2014-03-14 11:07 ` Johan Hedberg
  2014-03-14 11:30   ` Johan Hedberg
  3 siblings, 1 reply; 6+ messages in thread
From: Johan Hedberg @ 2014-03-14 11:07 UTC (permalink / raw)
  To: Natanael Copa; +Cc: linux-bluetooth

Hi Natanael,

On Fri, Mar 14, 2014, Natanael Copa wrote:
> The following fixes are needed to make bluez build on Alpine Linuz with
> musl libc.
> 
> This is kind of a rebase of the previously posted patches:
> http://www.spinics.net/lists/linux-bluetooth/msg43070.html
> 
> Changes since then are:
> - mention Alpine Linux in commit message
> - rebase to current git
> - added fix for proper header include for be32toh, htobe32 and htobe64
> 
> Please note that "unit: prevent unintended use of glibc's error(3)"
> fixes a bug in the unit test that affects glibc too. I suppose that if
> you add a testcase that triggers any error logging from sdpd-request.c
> it will likely segfault instead of gracfully hande the error condition.
> (it only affects the unit test though)
> 
> Natanael Copa (3):
>   shared: include endian.h for be32toh, htobe32 and htobe64 functions
>   unit: prevent unintended use of glibc's error(3)
>   bnep: avoid use of caddr_t
> 
>  Makefile.am             | 1 +
>  profiles/network/bnep.c | 4 ++--
>  src/shared/btsnoop.c    | 1 +
>  unit/test-sdp.c         | 9 +++------
>  4 files changed, 7 insertions(+), 8 deletions(-)

I've applied patches 1 and 3, but am waiting for a v2 on patch 2 since
it breaks the build:

unit/test-sdp.c: In function ‘main’:
unit/test-sdp.c:795:3: error: implicit declaration of function ‘__btd_log_init’ [-Werror=implicit-function-declaration]
   __btd_log_init("*", 0);

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Various build fixes for building bluez with musl libc
  2014-03-14 11:07 ` [PATCH 0/3] Various build fixes for building bluez with musl libc Johan Hedberg
@ 2014-03-14 11:30   ` Johan Hedberg
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2014-03-14 11:30 UTC (permalink / raw)
  To: Natanael Copa, linux-bluetooth

Hi,

On Fri, Mar 14, 2014, Johan Hedberg wrote:
> On Fri, Mar 14, 2014, Natanael Copa wrote:
> > The following fixes are needed to make bluez build on Alpine Linuz with
> > musl libc.
> > 
> > This is kind of a rebase of the previously posted patches:
> > http://www.spinics.net/lists/linux-bluetooth/msg43070.html
> > 
> > Changes since then are:
> > - mention Alpine Linux in commit message
> > - rebase to current git
> > - added fix for proper header include for be32toh, htobe32 and htobe64
> > 
> > Please note that "unit: prevent unintended use of glibc's error(3)"
> > fixes a bug in the unit test that affects glibc too. I suppose that if
> > you add a testcase that triggers any error logging from sdpd-request.c
> > it will likely segfault instead of gracfully hande the error condition.
> > (it only affects the unit test though)
> > 
> > Natanael Copa (3):
> >   shared: include endian.h for be32toh, htobe32 and htobe64 functions
> >   unit: prevent unintended use of glibc's error(3)
> >   bnep: avoid use of caddr_t
> > 
> >  Makefile.am             | 1 +
> >  profiles/network/bnep.c | 4 ++--
> >  src/shared/btsnoop.c    | 1 +
> >  unit/test-sdp.c         | 9 +++------
> >  4 files changed, 7 insertions(+), 8 deletions(-)
> 
> I've applied patches 1 and 3, but am waiting for a v2 on patch 2 since
> it breaks the build:
> 
> unit/test-sdp.c: In function ‘main’:
> unit/test-sdp.c:795:3: error: implicit declaration of function ‘__btd_log_init’ [-Werror=implicit-function-declaration]
>    __btd_log_init("*", 0);

I went ahead and fixed the missing include myself. The patch is now
applied.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-14 11:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-14  9:59 [PATCH 0/3] Various build fixes for building bluez with musl libc Natanael Copa
2014-03-14  9:59 ` [PATCH 1/3] shared: include endian.h for be32toh, htobe32 and htobe64 functions Natanael Copa
2014-03-14  9:59 ` [PATCH 2/3] unit: prevent unintended use of glibc's error(3) Natanael Copa
2014-03-14  9:59 ` [PATCH 3/3] bnep: avoid use of caddr_t Natanael Copa
2014-03-14 11:07 ` [PATCH 0/3] Various build fixes for building bluez with musl libc Johan Hedberg
2014-03-14 11:30   ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.