From 31ce367cd10087b532431c023e4a95513ecdee5d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 20 Nov 2020 11:45:35 +0100 Subject: lib/uuid.c: change prototype of uuid_guid_get_str() There's no reason to require an appropriately sized output parameter for the string, that's error-prone should the table ever grow an element with a longer string. We can just return the const char* pointer directly. Update the only caller accordingly, and get rid of pointless ifdeffery in the header so that the compiler always sees a declaration and can thus do type-checking, whether or not PARTITION_TYPE_GUID is enabled or not. Signed-off-by: Rasmus Villemoes --- lib/uuid.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/uuid.c b/lib/uuid.c index e62d5ca2643..6cfb6cd449d 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -122,20 +122,19 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin) * uuid_guid_get_str() - this function get string for GUID. * * @param guid_bin - pointer to string with partition type guid [16B] - * @param guid_str - pointer to allocated partition type string [7B] + * + * Returns NULL if the type GUID is not known. */ -int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str) +const char *uuid_guid_get_str(const unsigned char *guid_bin) { int i; - *guid_str = 0; for (i = 0; i < ARRAY_SIZE(list_guid); i++) { if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) { - strcpy(guid_str, list_guid[i].string); - return 0; + return list_guid[i].string; } } - return -ENODEV; + return NULL; } #endif -- cgit v1.2.3 From c0364ce1c6957c5295e933b95802e6966e00b08f Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 20 Nov 2020 11:45:36 +0100 Subject: doc/README.gpt: define partition type GUID for U-Boot environment When setting aside a GPT partition for holding the U-Boot environment, having a partition type GUID [1] indicating "Linux filesystem" (as most tools default to) is somewhat misleading - and there's no other well-known type GUID that is better suited. So to have a canonical value to put into the type field, define 3de21764-95bd-54bd-a5c3-4abe786f38a8 to mean a partition holding a U-Boot environment. This is a v5 namespace-name GUID [2], generated [3] from a namespace of "25cbcde0-8642-47c6-a298-1a3a57cd256b" and name "U-Boot environment". Should future type GUIDs be defined in the context of U-Boot, it's sensible to use that same namespace GUID. [1] https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs [2] https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based) [3] https://www.uuidtools.com/v5 Signed-off-by: Rasmus Villemoes --- lib/uuid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/uuid.c b/lib/uuid.c index 6cfb6cd449d..54a93aacc90 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -96,7 +96,8 @@ static const struct { {"linux", PARTITION_LINUX_FILE_SYSTEM_DATA_GUID}, {"raid", PARTITION_LINUX_RAID_GUID}, {"swap", PARTITION_LINUX_SWAP_GUID}, - {"lvm", PARTITION_LINUX_LVM_GUID} + {"lvm", PARTITION_LINUX_LVM_GUID}, + {"u-boot-env", PARTITION_U_BOOT_ENVIRONMENT}, }; /* -- cgit v1.2.3 From 976a68a20d366e6497253bad9fe0d7a8e42a611c Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 11 Dec 2020 14:59:23 +0100 Subject: string: Use memcpy() within memmove() when we can A common use of memmove() can be handled by memcpy(). Also memcpy() includes an optimization for large sizes: it copies a word at a time. So we can get a speed-up by calling memcpy() to handle our move in this case. Update memmove() to call also memcpy() if the source don't overlap the destination (src + count <= dest). Signed-off-by: Patrick Delaunay --- lib/string.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/string.c b/lib/string.c index ae7835f600d..73b984123dc 100644 --- a/lib/string.c +++ b/lib/string.c @@ -567,7 +567,19 @@ void * memmove(void * dest,const void *src,size_t count) { char *tmp, *s; - if (dest <= src) { + if (dest <= src || (src + count) <= dest) { + /* + * Use the fast memcpy implementation (ARCH optimized or lib/string.c) when it is possible: + * - when dest is before src (assuming that memcpy is doing forward-copying) + * - when destination don't overlap the source buffer (src + count <= dest) + * + * WARNING: the first optimisation cause an issue, when __HAVE_ARCH_MEMCPY is defined, + * __HAVE_ARCH_MEMMOVE is not defined and if the memcpy ARCH-specific + * implementation is not doing a forward-copying. + * + * No issue today because memcpy is doing a forward-copying in lib/string.c and for ARM32 + * architecture; no other arches use __HAVE_ARCH_MEMCPY without __HAVE_ARCH_MEMMOVE. + */ memcpy(dest, src, count); } else { tmp = (char *) dest + count; -- cgit v1.2.3 From 3e50deece014bc6e3dc57e85dc2b903630f7f69a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 28 Dec 2020 17:56:27 +0100 Subject: lib: aes: build failure with DEBUG=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building fails with DEBUG=1: lib/aes.c: In function ‘debug_print_vector’: lib/aes.c:622:45: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 622 | printf("%s [%d] @0x%08x", name, num_bytes, (u32)data); Pointers can only be cast to (uintptr_t). But anyway we have %p for printing pointers. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/aes.c b/lib/aes.c index c998aecb3c7..05ec2357024 100644 --- a/lib/aes.c +++ b/lib/aes.c @@ -619,7 +619,7 @@ void aes_decrypt(u32 key_len, u8 *in, u8 *expkey, u8 *out) static void debug_print_vector(char *name, u32 num_bytes, u8 *data) { #ifdef DEBUG - printf("%s [%d] @0x%08x", name, num_bytes, (u32)data); + printf("%s [%d] @0x%p", name, num_bytes, data); print_buffer(0, data, 1, num_bytes, 16); #endif } -- cgit v1.2.3 From 834427d46365e5e76ec5b23eca40063f7881c493 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 28 Dec 2020 21:31:43 +0100 Subject: lib: zlib: include ctype.h Our ctype.h is in include/linux/ Signed-off-by: Heinrich Schuchardt --- lib/zlib/trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/zlib/trees.c b/lib/zlib/trees.c index 3e09517ed0e..700c62f6d7b 100644 --- a/lib/zlib/trees.c +++ b/lib/zlib/trees.c @@ -38,7 +38,7 @@ #include "deflate.h" #ifdef DEBUG -# include +# include #endif /* =========================================================================== -- cgit v1.2.3 From 986c841c8b41ba3dc8d8bc4ce3802779cf69bfc0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 28 Dec 2020 21:41:40 +0100 Subject: lib: zlib: our putc() takes only one argument In contrast to the C99 standard [1] our putc() takes only one argument. [1] ISO/IEC 9899:1999 Signed-off-by: Heinrich Schuchardt --- lib/zlib/deflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/zlib/deflate.c b/lib/zlib/deflate.c index 1fe58d5da6c..63473359e45 100644 --- a/lib/zlib/deflate.c +++ b/lib/zlib/deflate.c @@ -1284,7 +1284,7 @@ local void check_match(s, start, match, length) } if (z_verbose > 1) { fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); + do { putc(s->window[start++]); } while (--length != 0); } } #else -- cgit v1.2.3 From 6205bbb1e04ee2f8e503581201cc1c7c3179b070 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 4 Jan 2021 15:33:28 +0100 Subject: lib: cosmetic update of CONFIG_LIB_ELF description Change 2 typo error in CONFIG_LIB_ELF description: - Supoort => Support - fir => for Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- lib/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Kconfig b/lib/Kconfig index a704568443c..88c43a38c3e 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -695,8 +695,8 @@ config LIB_DATE config LIB_ELF bool help - Supoort basic elf loading/validating functions. - This supports fir 32 bit and 64 bit versions. + Support basic elf loading/validating functions. + This supports for 32 bit and 64 bit versions. endmenu -- cgit v1.2.3