libbsd: Branch 'main' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Nov 27 22:43:59 UTC 2021


 src/getentropy_bsd.c |    2 ++
 src/local-link.h     |   10 +++++-----
 src/nlist.c          |    8 ++------
 test/fgetln.c        |    1 +
 4 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 1eba40602175e9ee231cba7577c3eee975680dcb
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 27 21:09:18 2021 +0100

    test: Check that strdup() does not fail
    
    Warned-by: gcc

diff --git a/test/fgetln.c b/test/fgetln.c
index 2eafa84..e137fe7 100644
--- a/test/fgetln.c
+++ b/test/fgetln.c
@@ -96,6 +96,7 @@ test_fgetln_multi(void)
 		char *str;
 
 		str = strdup("A\n");
+		assert(str);
 		str[0] += i;
 
 		files[i].line_alloc = str;
commit 8ad7570c20d2381a5e1962d9b1b813d44c080837
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 27 21:07:00 2021 +0100

    getentropy: Add missing prototype for BSD variant
    
    Warned-by: gcc

diff --git a/src/getentropy_bsd.c b/src/getentropy_bsd.c
index 705f65b..551b646 100644
--- a/src/getentropy_bsd.c
+++ b/src/getentropy_bsd.c
@@ -26,6 +26,8 @@
 #include <errno.h>
 #include <stddef.h>
 
+int	getentropy(void *buf, size_t len);
+
 /*
  * Derived from lib/libc/gen/arc4random.c from FreeBSD.
  */
commit 43a827031779650e63a5f787fc1959d146355153
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 27 20:26:05 2021 +0100

    nlist: Remove condition which is always true
    
    The nlist() function is limited to handle ELF binaries of the same class
    as size as the size_t of the architecture built.
    
    In addition the SIZE_T_MAX macro is BSD specific, and was falling back
    to the wrong constant on most 64-bit non-BSD systems.
    
    Warned-by: gcc

diff --git a/src/nlist.c b/src/nlist.c
index 8012d5a..1cb9d18 100644
--- a/src/nlist.c
+++ b/src/nlist.c
@@ -43,10 +43,6 @@
 
 #include "local-elf.h"
 
-#ifndef SIZE_T_MAX
-#define SIZE_T_MAX 0xffffffffU
-#endif
-
 /* Note: This function is used by libkvm0, so we need to export it.
  * It is not declared in the include files though. */
 int __fdnlist(int, struct nlist *);
@@ -153,7 +149,7 @@ __fdnlist(int fd, struct nlist *list)
 	shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
 
 	/* Make sure it's not too big to mmap */
-	if (shdr_size > SIZE_T_MAX || shdr_size > st.st_size) {
+	if (shdr_size > st.st_size) {
 		errno = EFBIG;
 		return (-1);
 	}
@@ -186,7 +182,7 @@ __fdnlist(int fd, struct nlist *list)
 	}
 
 	/* Check for files too large to mmap. */
-	if (symstrsize > SIZE_T_MAX || symstrsize > st.st_size) {
+	if (symstrsize > st.st_size) {
 		errno = EFBIG;
 		goto done;
 	}
commit 6a71b24b63ba403e6c49dbed2d31d9a73cab4890
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 27 22:52:28 2021 +0100

    build: Append __ after __attribute and __typeof keywords
    
    Be consistent with other usages in the code base.

diff --git a/src/local-link.h b/src/local-link.h
index fd1949c..ebc197f 100644
--- a/src/local-link.h
+++ b/src/local-link.h
@@ -37,11 +37,11 @@
 #  if __has_attribute(symver)
 /* The symver attribute is supported since gcc 10.x. */
 #define libbsd_symver_default(alias, symbol, version) \
-	extern __typeof(symbol) symbol \
-		__attribute((__symver__(#alias "@@" #version)))
+	extern __typeof__(symbol) symbol \
+		__attribute__((__symver__(#alias "@@" #version)))
 #define libbsd_symver_variant(alias, symbol, version) \
-	extern __typeof(symbol) symbol \
-		__attribute((__symver__(#alias "@" #version)))
+	extern __typeof__(symbol) symbol \
+		__attribute__((__symver__(#alias "@" #version)))
 #  else
 #define libbsd_symver_default(alias, symbol, version) \
 	__asm__(".symver " #symbol "," #alias "@@" #version)
@@ -51,7 +51,7 @@
 #  endif
 #else
 #define libbsd_symver_default(alias, symbol, version) \
-	extern __typeof(symbol) alias __attribute__((__alias__(#symbol)))
+	extern __typeof__(symbol) alias __attribute__((__alias__(#symbol)))
 
 #define libbsd_symver_variant(alias, symbol, version)
 #endif


More information about the libbsd mailing list