summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig11
-rw-r--r--lib/abuf.c58
-rw-r--r--lib/binman.c16
-rw-r--r--lib/efi/efi_stub.c2
-rw-r--r--lib/efi_loader/Kconfig7
-rw-r--r--lib/efi_loader/efi_bootmgr.c1
-rw-r--r--lib/efi_loader/efi_boottime.c2
-rw-r--r--lib/efi_loader/efi_device_path.c1
-rw-r--r--lib/efi_loader/efi_firmware.c1
-rw-r--r--lib/efi_loader/efi_net.c1
-rw-r--r--lib/fwu_updates/fwu_v1.c1
-rw-r--r--lib/fwu_updates/fwu_v2.c1
-rw-r--r--lib/linux_string.c6
-rw-r--r--lib/mbedtls/external/mbedtls/library/ecp_curves_new.c46
-rw-r--r--lib/of_live.c3
-rw-r--r--lib/slre.c78
-rw-r--r--lib/tiny-printf.c48
-rw-r--r--lib/trace.c4
18 files changed, 200 insertions, 87 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index b2aecd8a49e..6a89f797bef 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF
The supported format specifiers are %c, %s, %u/%d and %x.
+config SPL_USE_TINY_PRINTF_POINTER_SUPPORT
+ bool "Extend tiny printf with the pointer formatting %p"
+ depends on SPL_USE_TINY_PRINTF
+ help
+ This option enables the formatting of pointers %p. It supports
+ %p and %pa / %pap. If this option is selected by SPL_NET
+ it also supports the formatting with %pm, %pM and %pI4.
+
config PANIC_HANG
bool "Do not reset the system on fatal error"
help
@@ -275,7 +283,8 @@ config REGEX
choice
prompt "Pseudo-random library support type"
depends on NET_RANDOM_ETHADDR || RANDOM_UUID || CMD_UUID || \
- RNG_SANDBOX || UT_LIB && AES || FAT_WRITE
+ RNG_SANDBOX || UT_LIB && AES || FAT_WRITE || CMD_BOOTP || \
+ CMD_DHCP || CMD_DHCP6
default LIB_RAND
help
Select the library to provide pseudo-random number generator
diff --git a/lib/abuf.c b/lib/abuf.c
index 61adf7fc6b1..3a2fd1782e9 100644
--- a/lib/abuf.c
+++ b/lib/abuf.c
@@ -10,8 +10,11 @@
#include <malloc.h>
#include <mapmem.h>
#include <string.h>
+#include <vsprintf.h>
#endif
+#include <errno.h>
+#include <stdarg.h>
#include <abuf.h>
void abuf_set(struct abuf *abuf, void *data, size_t size)
@@ -119,6 +122,61 @@ void abuf_init_set(struct abuf *abuf, void *data, size_t size)
abuf_set(abuf, data, size);
}
+bool abuf_init_size(struct abuf *buf, size_t size)
+{
+ abuf_init(buf);
+ if (!abuf_realloc(buf, size))
+ return false;
+
+ return true;
+}
+
+bool abuf_copy(const struct abuf *old, struct abuf *copy)
+{
+ char *data;
+
+ data = malloc(old->size);
+ if (!data)
+ return false;
+ memcpy(data, old->data, old->size);
+ abuf_init_set(copy, data, old->size);
+ copy->alloced = true;
+
+ return true;
+}
+
+int abuf_printf(struct abuf *buf, const char *fmt, ...)
+{
+ int maxlen = buf->size;
+ va_list args;
+ int len;
+
+ va_start(args, fmt);
+ len = vsnprintf(buf->data, buf->size, fmt, args);
+ va_end(args);
+
+ /* add the terminator */
+ len++;
+
+ if (len > 4096)
+ return -E2BIG;
+ if (len > maxlen) {
+ /* make more space and try again */
+ maxlen = len;
+ if (!abuf_realloc(buf, maxlen))
+ return -ENOMEM;
+ va_start(args, fmt);
+ len = vsnprintf(buf->data, maxlen, fmt, args);
+ va_end(args);
+
+ /* check there isn't anything strange going on */
+ if (len > maxlen)
+ return -EFAULT;
+ }
+
+ return len;
+}
+
void abuf_init_const(struct abuf *abuf, const void *data, size_t size)
{
/* for now there is no flag indicating that the abuf data is constant */
diff --git a/lib/binman.c b/lib/binman.c
index 9047f5275f3..a594fe4c2ca 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -16,12 +16,15 @@
* struct binman_info - Information needed by the binman library
*
* @image: Node describing the image we are running from
+ * @skip_at_start: Number of bytes skipped at the start of the image. This is
+ * the value of the skip-at-start property for the image
* @rom_offset: Offset from an image_pos to the memory-mapped address, or
* ROM_OFFSET_NONE if the ROM is not memory-mapped. Can be positive or
* negative
*/
struct binman_info {
ofnode image;
+ uint skip_at_start;
int rom_offset;
};
@@ -80,7 +83,14 @@ static int binman_entry_find_internal(ofnode node, const char *name,
int binman_entry_find(const char *name, struct binman_entry *entry)
{
- return binman_entry_find_internal(binman->image, name, entry);
+ int ret;
+
+ ret = binman_entry_find_internal(binman->image, name, entry);
+ if (ret)
+ return log_msg_ret("bef", ret);
+ entry->image_pos -= binman->skip_at_start;
+
+ return 0;
}
int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep)
@@ -107,7 +117,7 @@ ofnode binman_section_find_node(const char *name)
void binman_set_rom_offset(int rom_offset)
{
- binman->rom_offset = rom_offset;
+ binman->rom_offset = rom_offset - binman->skip_at_start;
}
int binman_get_rom_offset(void)
@@ -140,10 +150,12 @@ int binman_init(void)
binman = malloc(sizeof(struct binman_info));
if (!binman)
return log_msg_ret("space for binman", -ENOMEM);
+ memset(binman, '\0', sizeof(struct binman_info));
ret = find_image_node(&binman->image);
if (ret)
return log_msg_ret("node", -ENOENT);
binman_set_rom_offset(ROM_OFFSET_NONE);
+ ofnode_read_u32(binman->image, "skip-at-start", &binman->skip_at_start);
log_debug("binman: Selected image node '%s'\n",
ofnode_get_name(binman->image));
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 40fc29d9adf..a083c7f1e9b 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -83,7 +83,7 @@ void puts(const char *str)
putc(*str++);
}
-static void _debug_uart_putc(int ch)
+static inline void _debug_uart_putc(int ch)
{
putc(ch);
}
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 7f02a83e2a2..3dadbc54b58 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -443,10 +443,9 @@ config EFI_TCG2_PROTOCOL_MEASURE_DTB
help
When enabled, the DTB image passed to the booted EFI image is
measured using the EFI TCG2 protocol. Do not enable this feature if
- the passed DTB contains data that change across platform reboots
- and cannot be used has a predictable measurement. Otherwise
- this feature allows better measurement of the system boot
- sequence.
+ the passed DTB contains data that changes across platform reboots
+ and cannot be used for a predictable measurement. Otherwise, this
+ feature allows for better measurement of the system boot sequence.
config EFI_LOAD_FILE2_INITRD
bool "EFI_FILE_LOAD2_PROTOCOL for Linux initial ramdisk"
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 1a3461f5a9d..b9437a81c64 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -13,6 +13,7 @@
#include <dm.h>
#include <efi.h>
#include <efi_device_path.h>
+#include <env.h>
#include <log.h>
#include <malloc.h>
#include <net.h>
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 24b0e52a2a2..754bc6a6519 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -58,7 +58,7 @@ static efi_handle_t current_image;
* restriction so we need to manually swap its and our view of that register on
* EFI callback entry/exit.
*/
-static volatile gd_t *efi_gd, *app_gd;
+static gd_t *efi_gd, *app_gd;
#endif
efi_status_t efi_uninstall_protocol
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 7316a76f462..b3fb20b2501 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <dm/root.h>
#include <efi_device_path.h>
+#include <ide.h>
#include <log.h>
#include <net.h>
#include <usb.h>
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index d44dc09813e..75501e21557 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -12,6 +12,7 @@
#include <dfu.h>
#include <efi_loader.h>
#include <efi_variable.h>
+#include <env.h>
#include <fwu.h>
#include <image.h>
#include <signatures.h>
diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index 8e708d8d350..86f0af9538c 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -19,6 +19,7 @@
#include <efi_device_path.h>
#include <efi_loader.h>
+#include <env.h>
#include <dm.h>
#include <linux/sizes.h>
#include <malloc.h>
diff --git a/lib/fwu_updates/fwu_v1.c b/lib/fwu_updates/fwu_v1.c
index c311a8857a6..974abf216f6 100644
--- a/lib/fwu_updates/fwu_v1.c
+++ b/lib/fwu_updates/fwu_v1.c
@@ -3,6 +3,7 @@
* Copyright (c) 2024, Linaro Limited
*/
+#include <errno.h>
#include <fwu.h>
#include <fwu_mdata.h>
diff --git a/lib/fwu_updates/fwu_v2.c b/lib/fwu_updates/fwu_v2.c
index ce46904ff2e..159315b45b9 100644
--- a/lib/fwu_updates/fwu_v2.c
+++ b/lib/fwu_updates/fwu_v2.c
@@ -3,6 +3,7 @@
* Copyright (c) 2024, Linaro Limited
*/
+#include <errno.h>
#include <fwu.h>
#include <fwu_mdata.h>
#include <log.h>
diff --git a/lib/linux_string.c b/lib/linux_string.c
index d5a5e08d98c..4b92cd923f2 100644
--- a/lib/linux_string.c
+++ b/lib/linux_string.c
@@ -31,13 +31,15 @@ char *skip_spaces(const char *str)
* Note that the first trailing whitespace is replaced with a %NUL-terminator
* in the given string @s. Returns a pointer to the first non-whitespace
* character in @s.
+ *
+ * Note that if the string consist of only spaces, then the terminator is placed
+ * at the start of the string, with the return value pointing there also.
*/
char *strim(char *s)
{
size_t size;
char *end;
- s = skip_spaces(s);
size = strlen(s);
if (!size)
return s;
@@ -47,5 +49,5 @@ char *strim(char *s)
end--;
*(end + 1) = '\0';
- return s;
+ return skip_spaces(s);
}
diff --git a/lib/mbedtls/external/mbedtls/library/ecp_curves_new.c b/lib/mbedtls/external/mbedtls/library/ecp_curves_new.c
index 035b23a1b41..0275661887b 100644
--- a/lib/mbedtls/external/mbedtls/library/ecp_curves_new.c
+++ b/lib/mbedtls/external/mbedtls/library/ecp_curves_new.c
@@ -4644,17 +4644,17 @@ static const mbedtls_mpi_sint curve25519_a24 = 0x01DB42;
/* P = 2^255 - 19 */
static const mbedtls_mpi_uint curve25519_p[] = {
- MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7F)
+ MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F)
};
/* N = 2^252 + 27742317777372353535851937790883648493 */
static const mbedtls_mpi_uint curve25519_n[] = {
- MBEDTLS_BYTES_TO_T_UINT_8(0XED, 0XD3, 0XF5, 0X5C, 0X1A, 0X63, 0X12, 0X58),
- MBEDTLS_BYTES_TO_T_UINT_8(0XD6, 0X9C, 0XF7, 0XA2, 0XDE, 0XF9, 0XDE, 0X14),
- MBEDTLS_BYTES_TO_T_UINT_8(0X00, 0X00, 0X00, 0X00, 0x00, 0x00, 0x00, 0x00),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xED, 0xD3, 0xF5, 0x5C, 0x1A, 0x63, 0x12, 0x58),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xD6, 0x9C, 0xF7, 0xA2, 0xDE, 0xF9, 0xDE, 0x14),
+ MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10)
};
@@ -4698,26 +4698,26 @@ static const mbedtls_mpi_sint curve448_a24 = 0x98AA;
/* P = 2^448 - 2^224 - 1 */
static const mbedtls_mpi_uint curve448_p[] = {
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00)
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
};
/* N = 2^446 - 13818066809895115352007386748515426880336692474882178609894547503885 */
static const mbedtls_mpi_uint curve448_n[] = {
- MBEDTLS_BYTES_TO_T_UINT_8(0XF3, 0X44, 0X58, 0XAB, 0X92, 0XC2, 0X78, 0X23),
- MBEDTLS_BYTES_TO_T_UINT_8(0X55, 0X8F, 0XC5, 0X8D, 0X72, 0XC2, 0X6C, 0X21),
- MBEDTLS_BYTES_TO_T_UINT_8(0X90, 0X36, 0XD6, 0XAE, 0X49, 0XDB, 0X4E, 0XC4),
- MBEDTLS_BYTES_TO_T_UINT_8(0XE9, 0X23, 0XCA, 0X7C, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF),
- MBEDTLS_BYTES_TO_T_UINT_8(0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X3F),
- MBEDTLS_BYTES_TO_T_UINT_8(0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00)
+ MBEDTLS_BYTES_TO_T_UINT_8(0xF3, 0x44, 0x58, 0xAB, 0x92, 0xC2, 0x78, 0x23),
+ MBEDTLS_BYTES_TO_T_UINT_8(0x55, 0x8F, 0xC5, 0x8D, 0x72, 0xC2, 0x6C, 0x21),
+ MBEDTLS_BYTES_TO_T_UINT_8(0x90, 0x36, 0xD6, 0xAE, 0x49, 0xDB, 0x4E, 0xC4),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xE9, 0x23, 0xCA, 0x7C, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),
+ MBEDTLS_BYTES_TO_T_UINT_8(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F),
+ MBEDTLS_BYTES_TO_T_UINT_8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
};
/*
diff --git a/lib/of_live.c b/lib/of_live.c
index c1620616513..24200b948a6 100644
--- a/lib/of_live.c
+++ b/lib/of_live.c
@@ -448,8 +448,7 @@ int of_live_flatten(const struct device_node *root, struct abuf *buf)
{
int ret;
- abuf_init(buf);
- if (!abuf_realloc(buf, BUF_STEP))
+ if (!abuf_init_size(buf, BUF_STEP))
return log_msg_ret("ini", -ENOMEM);
ret = fdt_create(abuf_data(buf), abuf_size(buf));
diff --git a/lib/slre.c b/lib/slre.c
index 277a59a03a7..117815a6d60 100644
--- a/lib/slre.c
+++ b/lib/slre.c
@@ -30,7 +30,7 @@
#include <slre.h>
enum {END, BRANCH, ANY, EXACT, ANYOF, ANYBUT, OPEN, CLOSE, BOL, EOL,
- STAR, PLUS, STARQ, PLUSQ, QUEST, SPACE, NONSPACE, DIGIT};
+ STAR, PLUS, STARQ, PLUSQ, QUEST, SPACE, NONSPACE, DIGIT, RANGE};
#ifdef SLRE_TEST
static struct {
@@ -55,7 +55,8 @@ static struct {
{"QUEST", 1, "o"}, /* Match zero or one time, "?" */
{"SPACE", 0, ""}, /* Match whitespace, "\s" */
{"NONSPACE", 0, ""}, /* Match non-space, "\S" */
- {"DIGIT", 0, ""} /* Match digit, "\d" */
+ {"DIGIT", 0, ""}, /* Match digit, "\d" */
+ {"RANGE", 0, ""}, /* Range separator - */
};
#endif /* SLRE_TEST */
@@ -260,6 +261,15 @@ anyof(struct slre *r, const char **re)
return;
/* NOTREACHED */
break;
+ case '-':
+ if (r->data_size == old_data_size || **re == ']') {
+ /* First or last character, just match - itself. */
+ store_char_in_data(r, '-');
+ break;
+ }
+ store_char_in_data(r, 0);
+ store_char_in_data(r, RANGE);
+ break;
case '\\':
esc = get_escape_char(re);
if ((esc & 0xff) == 0) {
@@ -413,10 +423,7 @@ int
slre_compile(struct slre *r, const char *re)
{
r->err_str = NULL;
- r->code_size = r->data_size = r->num_caps = r->anchored = 0;
-
- if (*re == '^')
- r->anchored++;
+ r->code_size = r->data_size = r->num_caps = 0;
emit(r, OPEN); /* This will capture what matches full RE */
emit(r, 0);
@@ -475,29 +482,54 @@ is_any_of(const unsigned char *p, int len, const char *s, int *ofs)
ch = s[*ofs];
- for (i = 0; i < len; i++)
- if (p[i] == ch) {
- (*ofs)++;
- return 1;
+ for (i = 0; i < len; i++) {
+ if (p[i] == '\0') {
+ switch (p[++i]) {
+ case NONSPACE:
+ if (!isspace(ch))
+ goto match;
+ break;
+ case SPACE:
+ if (isspace(ch))
+ goto match;
+ break;
+ case DIGIT:
+ if (isdigit(ch))
+ goto match;
+ break;
+ case RANGE:
+ /*
+ * a-z is represented in the data array as {'a', \0, RANGE, 'z'}
+ */
+ ++i;
+ if (p[i - 3] <= (unsigned char)ch && (unsigned char)ch <= p[i])
+ goto match;
+ break;
+ }
+ continue;
}
+ if (p[i] == ch)
+ goto match;
+ }
return 0;
+
+match:
+ (*ofs)++;
+ return 1;
}
static int
is_any_but(const unsigned char *p, int len, const char *s, int *ofs)
{
- int i, ch;
-
- ch = s[*ofs];
+ int dummy = *ofs;
- for (i = 0; i < len; i++) {
- if (p[i] == ch)
- return 0;
+ if (is_any_of(p, len, s, &dummy)) {
+ return 0;
+ } else {
+ (*ofs)++;
+ return 1;
}
-
- (*ofs)++;
- return 1;
}
static int
@@ -650,13 +682,9 @@ slre_match(const struct slre *r, const char *buf, int len,
{
int i, ofs = 0, res = 0;
- if (r->anchored) {
+ for (i = 0; i <= len && res == 0; i++) {
+ ofs = i;
res = match(r, 0, buf, len, &ofs, caps);
- } else {
- for (i = 0; i < len && res == 0; i++) {
- ofs = i;
- res = match(r, 0, buf, len, &ofs, caps);
- }
}
return res;
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 2a7a4d286c0..411ae6189f2 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -141,7 +141,7 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr)
string(info, ip4_addr);
}
-#endif
+#endif /* CONFIG_SPL_NET */
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
@@ -157,18 +157,14 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr)
* decimal).
*/
-static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
- void *ptr)
+#if defined(CONFIG_SPL_USE_TINY_PRINTF_POINTER_SUPPORT) || defined(DEBUG)
+static void pointer(struct printf_info *info, const char *fmt, void *ptr)
{
-#ifdef DEBUG
unsigned long num = (uintptr_t)ptr;
unsigned long div;
-#endif
switch (*fmt) {
-#ifdef DEBUG
case 'a':
-
switch (fmt[1]) {
case 'p':
default:
@@ -176,7 +172,6 @@ static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
break;
}
break;
-#endif
#ifdef CONFIG_SPL_NET
case 'm':
return mac_address_string(info, ptr, false);
@@ -185,16 +180,22 @@ static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
case 'I':
if (fmt[1] == '4')
return ip4_addr_string(info, ptr);
+#else
+ case 'm':
+ case 'M':
+ case 'I':
+ out(info, '?');
+ return;
#endif
default:
break;
}
-#ifdef DEBUG
+
div = 1UL << (sizeof(long) * 8 - 4);
for (; div; div /= 0x10)
div_out(info, &num, div);
-#endif
}
+#endif
static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
{
@@ -269,21 +270,18 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
div_out(info, &num, div);
}
break;
+#if defined(CONFIG_SPL_USE_TINY_PRINTF_POINTER_SUPPORT) || defined(DEBUG)
case 'p':
- if (CONFIG_IS_ENABLED(NET) ||
- CONFIG_IS_ENABLED(NET_LWIP) || _DEBUG) {
- pointer(info, fmt, va_arg(va, void *));
- /*
- * Skip this because it pulls in _ctype which is
- * 256 bytes, and we don't generally implement
- * pointer anyway
- */
- while (isalnum(fmt[0]))
- fmt++;
- break;
- }
- islong = true;
- fallthrough;
+ pointer(info, fmt, va_arg(va, void *));
+ /*
+ * Skip this because it pulls in _ctype which is
+ * 256 bytes, and we don't generally implement
+ * pointer anyway
+ */
+ while (isalnum(fmt[0]))
+ fmt++;
+ break;
+#endif
case 'x':
case 'X':
if (islong) {
@@ -310,7 +308,9 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
break;
case '%':
out(info, '%');
+ break;
default:
+ out(info, '?');
break;
}
diff --git a/lib/trace.c b/lib/trace.c
index 1d5f7dec979..3d54dfaddc0 100644
--- a/lib/trace.c
+++ b/lib/trace.c
@@ -66,7 +66,7 @@ static inline uintptr_t __attribute__((no_instrument_function))
/**
* trace_gd - the value of the gd register
*/
-static volatile gd_t *trace_gd;
+static gd_t *trace_gd;
/**
* trace_save_gd() - save the value of the gd register
@@ -86,7 +86,7 @@ static void notrace trace_save_gd(void)
*/
static void notrace trace_swap_gd(void)
{
- volatile gd_t *temp_gd = trace_gd;
+ gd_t *temp_gd = trace_gd;
trace_gd = gd;
set_gd(temp_gd);