~mcf/libtls-bearssl

3 2

[PATCH 2/3] Remove unused _DEFAULT_SOURCE

Details
Message ID
<20200819185441.24226-2-issam.e.maghni@mailbox.org>
DKIM signature
missing
Download raw message
Patch: +1 -1
Signed-off-by: Issam E. Maghni <issam.e.maghni@mailbox.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8b0f7fd..f0979ec 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ PREFIX?=/usr/local
INCDIR?=$(PREFIX)/include
LIBDIR?=$(PREFIX)/lib
MANDIR?=$(PREFIX)/share/man
CFLAGS+=-Wall -Wpedantic -D _DEFAULT_SOURCE -I include
CFLAGS+=-Wall -Wpedantic -I include

OBJ=\
	src/tls.o\
-- 
2.28.0
Details
Message ID
<CAGw6cBuTWmqZWS9zQZb9-yKcBa0MvFKWysgf_mCZO9dzopTkMg@mail.gmail.com>
In-Reply-To
<20200819185441.24226-2-issam.e.maghni@mailbox.org> (view parent)
DKIM signature
missing
Download raw message
These last two patches remove _DEFAULT_SOURCE and then add
_GNU_SOURCE, but only for one file (tls.c).

The following non-POSIX functions are used by libtls-bearssl:
- strsep (tls_config.c, bearssl.c)
- [v]asprintf (tls.c)
- explicit_bzero (tls_conninfo.c tls_keypair.c compat/freezero.c)

strsep and explicit_bzero originated on BSD, as well as libtls itself,
which is why I had the project-wide _DEFAULT_SOURCE (this is used on
Linux to enable BSD extensions, along with some other stuff).

But, I think the problem you are trying to address is that glibc
doesn't expose [v]asprintf without _GNU_SOURCE (though on all other
libcs I checked, _DEFAULT_SOURCE is sufficient). BSDs ignore
_GNU_SOURCE/_DEFAULT_SOURCE anyway, so I think it makes sense to just
switch to _GNU_SOURCE project-wide.

Could you send a v2 which switches to _GNU_SOURCE rather than removing
_DEFAULT_SOURCE (since that causes a bunch of implicit declarations on
musl)?

Thanks
Details
Message ID
<C6ENSTJ2DH0Y.ROJWOLY9BKHS@v01d>
In-Reply-To
<CAGw6cBuTWmqZWS9zQZb9-yKcBa0MvFKWysgf_mCZO9dzopTkMg@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
How about adding this to tls_conninfo.c, tls_keypair.c an
compat/freezero.c:
/* explicit_bzero */
#define _GNU_SOURCE

To tls_config.c and bearssl.c:
/* strsep */
#define _GNU_SOURCE

I find that using global _GNU_SOURCE is a bad idea because you are
forced to add it into all the build system. I prefer to keep the compile
arguments minimal, and compilation units self sufficient.

WDYT?
Details
Message ID
<CAGw6cBs_mXOR6ONzFqxhdEd9oOoaqL0294ADKm7jVEh+ouTLyA@mail.gmail.com>
In-Reply-To
<C6ENSTJ2DH0Y.ROJWOLY9BKHS@v01d> (view parent)
DKIM signature
missing
Download raw message
On 2020-10-16, Issam E. Maghni <issam.e.maghni@mailbox.org> wrote:
> How about adding this to tls_conninfo.c, tls_keypair.c an
> compat/freezero.c:
> /* explicit_bzero */
> #define _GNU_SOURCE
>
> To tls_config.c and bearssl.c:
> /* strsep */
> #define _GNU_SOURCE
>
> I find that using global _GNU_SOURCE is a bad idea because you are
> forced to add it into all the build system. I prefer to keep the compile
> arguments minimal, and compilation units self sufficient.
>
> WDYT?

I prefer using a single define here. It is just one additional compile
flag, and not really a big deal to add into a build system.

I went ahead and pushed a commit to switch to _GNU_SOURCE.

Thanks for reporting the issue!
Reply to thread Export thread (mbox)