libbsd: Branch 'master' - 6 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Dec 21 18:05:04 UTC 2020
configure.ac | 19 +++++++++++++++++++
include/bsd/stdlib.h | 2 +-
man/Makefile.am | 1 +
man/bitstring.3bsd | 4 ++++
man/byteorder.3bsd | 4 ++++
man/queue.3bsd | 4 ++++
man/timespec.3bsd | 1 +
man/tree.3bsd | 4 ++++
src/Makefile.am | 5 ++++-
src/funopen.c | 8 ++++----
test/fgetln.c | 13 +++++++++++--
test/setmode.c | 20 ++++++++++++++++----
12 files changed, 73 insertions(+), 12 deletions(-)
New commits:
commit eac4ce0c674cf5051e3c90afda74db6718b0518d
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Sep 20 03:30:20 2020 +0200
man: Add a timespec(3bsd) alias to timeval(3bsd)
Even though man-pages project now includes man pages for system data
types, we still include these for any other system that does not have
them, to provide a self-contained project with code and documentation.
diff --git a/man/Makefile.am b/man/Makefile.am
index 26e893a..e3b27da 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -223,6 +223,7 @@ dist_man_MANS = \
timercmp.3bsd \
timerisset.3bsd \
timersub.3bsd \
+ timespec.3bsd \
timespecadd.3bsd \
timespecclear.3bsd \
timespeccmp.3bsd \
diff --git a/man/timespec.3bsd b/man/timespec.3bsd
new file mode 100644
index 0000000..e47176e
--- /dev/null
+++ b/man/timespec.3bsd
@@ -0,0 +1 @@
+.so man3/timeval.3bsd
commit 5ecff0c9034243d5277c5f27ff2b620770ffc72a
Author: Guillem Jover <guillem at hadrons.org>
Date: Wed Sep 16 23:41:28 2020 +0200
man: Add missing LIBRARY section
diff --git a/man/bitstring.3bsd b/man/bitstring.3bsd
index 4708ce1..6006af0 100644
--- a/man/bitstring.3bsd
+++ b/man/bitstring.3bsd
@@ -44,6 +44,10 @@
.Nm bitstr_size ,
.Nm bit_test
.Nd bit-string manipulation macros
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
+.Lb libbsd
.Sh SYNOPSIS
.In bitstring.h
(See
diff --git a/man/byteorder.3bsd b/man/byteorder.3bsd
index d79df43..5e5d6d3 100644
--- a/man/byteorder.3bsd
+++ b/man/byteorder.3bsd
@@ -31,6 +31,10 @@
.Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,
.Nm le16enc , le16dec , le32enc , le32dec , le64enc , le64dec
.Nd byte order operations
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
+.Lb libbsd
.Sh SYNOPSIS
.In sys/endian.h
(See
diff --git a/man/queue.3bsd b/man/queue.3bsd
index c11137f..8900f86 100644
--- a/man/queue.3bsd
+++ b/man/queue.3bsd
@@ -112,6 +112,10 @@
.Nm TAILQ_SWAP
.Nd implementations of singly-linked lists, singly-linked tail queues,
lists and tail queues
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
+.Lb libbsd
.Sh SYNOPSIS
.In sys/queue.h
(See
diff --git a/man/tree.3bsd b/man/tree.3bsd
index 1293674..6800c74 100644
--- a/man/tree.3bsd
+++ b/man/tree.3bsd
@@ -75,6 +75,10 @@
.Nm RB_INSERT ,
.Nm RB_REMOVE
.Nd implementations of splay and red-black trees
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
+.Lb libbsd
.Sh SYNOPSIS
.In sys/tree.h
(See
commit 8c5a83d678cc438f53023346afe64fa3e09e15cc
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Sep 20 03:32:57 2020 +0200
Fix coding style
diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
index a5b063c..ea3251d 100644
--- a/include/bsd/stdlib.h
+++ b/include/bsd/stdlib.h
@@ -62,7 +62,7 @@ int dehumanize_number(const char *str, int64_t *size);
const char *getprogname(void);
void setprogname(const char *);
-int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
+int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
int mergesort(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *));
int radixsort(const unsigned char **base, int nmemb,
commit d5b04ab19cf2273becb0b95274964c02f8b26c66
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Aug 16 22:01:42 2020 +0200
test: Fix short lived memory leaks
These are non-issues, but having a clean ASAN test suite makes it
possible to detect actual problems in the tested code.
Warned-by: gcc ASAN
diff --git a/test/fgetln.c b/test/fgetln.c
index 7d1e9dc..5e04281 100644
--- a/test/fgetln.c
+++ b/test/fgetln.c
@@ -61,6 +61,7 @@ static const wchar_t *data_wide[] = {
struct file {
FILE *fp;
+ void *line_alloc;
const void **lines;
const void *got_buf;
@@ -97,6 +98,7 @@ test_fgetln_multi(void)
str = strdup("A\n");
str[0] += i;
+ files[i].line_alloc = str;
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
files[i].lines[0] = str;
files[i].lines[1] = str;
@@ -123,8 +125,11 @@ test_fgetln_multi(void)
}
}
- for (i = 0; i < LINE_COUNT; i++)
+ for (i = 0; i < FILE_COUNT; i++) {
+ free(files[i].line_alloc);
+ free(files[i].lines);
pipe_close(files[i].fp);
+ }
}
static void
@@ -159,6 +164,7 @@ test_fgetwln_multi(void)
wstr = wcsdup(L"A\n");
wstr[0] += i;
+ files[i].line_alloc = wstr;
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
files[i].lines[0] = wstr;
files[i].lines[1] = wstr;
@@ -185,8 +191,11 @@ test_fgetwln_multi(void)
}
}
- for (i = 0; i < LINE_COUNT; i++)
+ for (i = 0; i < FILE_COUNT; i++) {
+ free(files[i].line_alloc);
+ free(files[i].lines);
pipe_close(files[i].fp);
+ }
}
static void
diff --git a/test/setmode.c b/test/setmode.c
index c6fbcba..c72deb8 100644
--- a/test/setmode.c
+++ b/test/setmode.c
@@ -25,19 +25,31 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
+ void *set;
+
umask(0);
- assert(getmode(setmode("0"), 0) == 0);
+ set = setmode("0");
+ assert(getmode(set, 0) == 0);
+ free(set);
+
+ set = setmode("7777");
+ assert(getmode(set, 0) == 07777);
+ free(set);
- assert(getmode(setmode("7777"), 0) == 07777);
- assert(getmode(setmode("1555"), 0) == 01555);
+ set = setmode("1555");
+ assert(getmode(set, 0) == 01555);
+ free(set);
- assert(getmode(setmode("ugo=rwx"), 0) == 0777);
+ set = setmode("ugo=rwx");
+ assert(getmode(set, 0) == 0777);
+ free(set);
/* FIXME: Complete unit tests. */
commit cfeafeabad1d415e55afb0bdc0c7b2244b4bac10
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Aug 16 21:58:04 2020 +0200
funopen: Fix memory leak in funopen_close() when closefn is NULL
We need to free the cookiewrap even when the closefn method is NULL.
Warned-by: gcc ASAN
diff --git a/src/funopen.c b/src/funopen.c
index 1e05c7e..1d908bc 100644
--- a/src/funopen.c
+++ b/src/funopen.c
@@ -87,10 +87,10 @@ funopen_close(void *cookie)
struct funopen_cookie *cookiewrap = cookie;
int rc;
- if (cookiewrap->closefn == NULL)
- return 0;
-
- rc = cookiewrap->closefn(cookiewrap->orig_cookie);
+ if (cookiewrap->closefn)
+ rc = cookiewrap->closefn(cookiewrap->orig_cookie);
+ else
+ rc = 0;
free(cookiewrap);
commit 3d6b6ead64d0c822790fb017c1ad97676af5c3b9
Author: Guillem Jover <guillem at hadrons.org>
Date: Sat Nov 16 00:04:18 2019 +0100
build: Detect support for --version-script in ld
diff --git a/configure.ac b/configure.ac
index 6e9496d..e8d4c5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,25 @@ AC_SYS_LARGEFILE
LT_INIT
+AC_CACHE_CHECK([if ld supports --version-script flag],
+ [libbsd_cv_version_script], [
+ echo "{ global: symbol; local: *; };" >conftest.map
+ save_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([], [])
+ ], [
+ libbsd_cv_version_script=yes
+ ], [
+ libbsd_cv_version_script=no
+ ])
+ LDFLAGS="$save_LDFLAGS"
+ rm -f conftest.map
+ ]
+)
+AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
+ [test "x$libbsd_cv_version_script" = "xyes"])
+
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
diff --git a/src/Makefile.am b/src/Makefile.am
index 8384b92..c4229cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,8 +65,11 @@ libbsd_la_LIBADD = \
$(ARC4RANDOM_ATFORK_LIBS) \
$(nil)
libbsd_la_LDFLAGS = \
- -Wl,--version-script=$(srcdir)/libbsd.map \
-version-number $(LIBBSD_ABI)
+if HAVE_LINKER_VERSION_SCRIPT
+libbsd_la_LDFLAGS += \
+ -Wl,--version-script=$(srcdir)/libbsd.map
+endif
libbsd_la_SOURCES = \
arc4random.c \
arc4random.h \
More information about the libbsd
mailing list