* [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library
@ 2015-09-09 13:16 Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with " Christophe Vu-Brugier
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christophe Vu-Brugier @ 2015-09-09 13:16 UTC (permalink / raw)
To: drbd-dev
Hi,
Here are two patches that fix compilation errors when drbd-utils is
built with the musl C library.
The errors were encountered when building drbd-utils with Buildroot,
an embedded build system that supports musl toolchains. Buildroot has
a nice build bot that builds a set of packages for several target
architectures and with several toolchains. drbd-utils builds currently
fail when the build is performed with a musl toolchain.
Here is an example of a build that failed:
http://autobuild.buildroot.net/results/b6a/b6aa71e60f2db5f3378186e06a11d7bbca0f2eb5/build-end.log
Christophe Vu-Brugier (2):
drbd_endian: fix compilation error with the musl C library
drbdmeta: drop usage of strndupa() which is not provided by musl
user/shared/drbd_endian.h | 2 +-
user/shared/drbdmeta.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
--
2.5.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with the musl C library
2015-09-09 13:16 [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Christophe Vu-Brugier
@ 2015-09-09 13:16 ` Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 2/2] drbdmeta: drop usage of strndupa() which is not provided by musl Christophe Vu-Brugier
2015-09-09 13:33 ` [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Roland Kammerer
2 siblings, 0 replies; 5+ messages in thread
From: Christophe Vu-Brugier @ 2015-09-09 13:16 UTC (permalink / raw)
To: drbd-dev
drbd-utils does not build with the musl C library due to the following
define directive:
#define BITS_PER_LONG __WORDSIZE
The musl C library does not define __WORDSIZE unless <sys/reg.h> is
included. However, including <sys/reg.h> looks weird and does not work
with old compilers.
This patch defines BITS_PER_LONG in a more portable way:
#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
---
user/shared/drbd_endian.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user/shared/drbd_endian.h b/user/shared/drbd_endian.h
index 014516f..8d8d43e 100644
--- a/user/shared/drbd_endian.h
+++ b/user/shared/drbd_endian.h
@@ -15,7 +15,7 @@
#include <endian.h>
#ifndef BITS_PER_LONG
-# define BITS_PER_LONG __WORDSIZE
+# define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
#endif
/* linux/byteorder/swab.h */
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Drbd-dev] [PATCH 2/2] drbdmeta: drop usage of strndupa() which is not provided by musl
2015-09-09 13:16 [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with " Christophe Vu-Brugier
@ 2015-09-09 13:16 ` Christophe Vu-Brugier
2015-09-09 13:33 ` [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Roland Kammerer
2 siblings, 0 replies; 5+ messages in thread
From: Christophe Vu-Brugier @ 2015-09-09 13:16 UTC (permalink / raw)
To: drbd-dev
The musl C library does not support strndupa() which is an
implementation of strndup() that allocates its buffer on the stack.
This patch changes drbd_str_disk() to compute the string length up to
the first slash (if any) and use the length to match the string with
the state names.
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
---
user/shared/drbdmeta.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/user/shared/drbdmeta.c b/user/shared/drbdmeta.c
index 82482e0..d700747 100644
--- a/user/shared/drbdmeta.c
+++ b/user/shared/drbdmeta.c
@@ -4819,17 +4819,17 @@ static enum drbd_disk_state drbd_str_disk(const char *str)
/* drbd 8.4 and earlier provide "Local/Remote"
* drbd 9. only "Local". */
const char *slash = strchr(str, '/');
- const char *tmp;
+ size_t len;
int n;
if (slash)
- tmp = strndupa(str, slash - str);
+ len = slash - str;
else
- tmp = str;
+ len = strlen(str);
for (n = 0; n < drbd_disk_state_names.size; n++) {
if (drbd_disk_state_names.names[n] &&
- !strcmp(tmp, drbd_disk_state_names.names[n]))
+ !strncmp(str, drbd_disk_state_names.names[n], len))
return (enum drbd_disk_state)n;
}
if (!strcmp(str, "Unconfigured"))
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library
2015-09-09 13:16 [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with " Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 2/2] drbdmeta: drop usage of strndupa() which is not provided by musl Christophe Vu-Brugier
@ 2015-09-09 13:33 ` Roland Kammerer
2015-09-09 14:23 ` Roland Kammerer
2 siblings, 1 reply; 5+ messages in thread
From: Roland Kammerer @ 2015-09-09 13:33 UTC (permalink / raw)
To: drbd-dev
On Wed, Sep 09, 2015 at 03:16:05PM +0200, Christophe Vu-Brugier wrote:
> Hi,
>
> Here are two patches that fix compilation errors when drbd-utils is
> built with the musl C library.
>
Hi Christophe,
I like the musl libc and will review the patches in the next days.
Thanks, rck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library
2015-09-09 13:33 ` [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Roland Kammerer
@ 2015-09-09 14:23 ` Roland Kammerer
0 siblings, 0 replies; 5+ messages in thread
From: Roland Kammerer @ 2015-09-09 14:23 UTC (permalink / raw)
To: drbd-dev
On Wed, Sep 09, 2015 at 03:33:54PM +0200, Roland Kammerer wrote:
> On Wed, Sep 09, 2015 at 03:16:05PM +0200, Christophe Vu-Brugier wrote:
> > Hi,
> >
> > Here are two patches that fix compilation errors when drbd-utils is
> > built with the musl C library.
> >
>
> Hi Christophe,
>
> I like the musl libc and will review the patches in the next days.
>
> Thanks, rck
Committed to our internal tree. Will take some time till it shows up in
the public repo.
Regards, rck
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-09 14:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-09 13:16 [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with " Christophe Vu-Brugier
2015-09-09 13:16 ` [Drbd-dev] [PATCH 2/2] drbdmeta: drop usage of strndupa() which is not provided by musl Christophe Vu-Brugier
2015-09-09 13:33 ` [Drbd-dev] [PATCH 0/2] drbd-utils: build fixes for the musl C library Roland Kammerer
2015-09-09 14:23 ` Roland Kammerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox