diff options
author | Julius Werner <jwerner@chromium.org> | 2024-03-19 13:29:39 -0700 |
---|---|---|
committer | Nick Vaccaro <nvaccaro@google.com> | 2024-03-19 22:50:03 +0000 |
commit | 6b4522e2aa40b6c97929342716ad61e32a694cce (patch) | |
tree | fdeffd4abfb35e61073931db2bc655277ec173ff /payloads/libpayload | |
parent | ebc6f9d2e17a0f85fd127c11723b5bb461f93441 (diff) |
libpayload: gdb: Make die_if() format string a literal
CB:77969 made minor changes to the die_if() macro. One of the
consequences is that the format string passed to it can no longer be a
real `char *` variable, it needs to actually be a string literal. In the
vast majority of call sites that is already the case, but there was one
instance in the GDB code where we're reusing the same format string many
times and for that reason put it into a const variable. Fix that by
turning it into a #define macro instead. (Even though this technically
duplicates the format string, the linker is able to merge identical
string literals together again, so it doesn't really end up taking more
space.)
Change-Id: I532a04b868f12aa0e3c01422c075ddaade251827
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81361
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/gdb/transport.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/payloads/libpayload/gdb/transport.c b/payloads/libpayload/gdb/transport.c index 5b575d0d83..66a6f20b94 100644 --- a/payloads/libpayload/gdb/transport.c +++ b/payloads/libpayload/gdb/transport.c @@ -16,12 +16,12 @@ #include <gdb.h> #include <libpayload.h> +#define OUTPUT_OVERRUN_MSG "GDB output buffer overrun (try increasing reply.size)!\n" + /* MMIO word size is not standardized, but *usually* 32 (even on ARM64) */ typedef u32 mmio_word_t; static const int timeout_us = 100 * 1000; -static const char output_overrun[] = "GDB output buffer overrun (try " - "increasing reply.size)!\n"; /* Serial-specific glue code... add more transport layers here when desired. */ @@ -77,7 +77,7 @@ static char to_hex(u8 v) void gdb_message_encode_bytes(struct gdb_message *message, const void *data, int length) { - die_if(message->used + length * 2 > message->size, output_overrun); + die_if(message->used + length * 2 > message->size, OUTPUT_OVERRUN_MSG); const mmio_word_t *aligned = (mmio_word_t *)ALIGN_DOWN((uintptr_t)data, sizeof(*aligned)); mmio_word_t word = be32toh(readl(aligned++)); @@ -114,7 +114,7 @@ void gdb_message_decode_bytes(const struct gdb_message *message, int offset, void gdb_message_encode_zero_bytes(struct gdb_message *message, int length) { - die_if(message->used + length * 2 > message->size, output_overrun); + die_if(message->used + length * 2 > message->size, OUTPUT_OVERRUN_MSG); memset(message->buf + message->used, '0', length * 2); message->used += length * 2; } @@ -125,13 +125,13 @@ void gdb_message_add_string(struct gdb_message *message, const char *string) string, message->size - message->used); /* Check >= instead of > to account for strlcpy's trailing '\0'. */ - die_if(message->used >= message->size, output_overrun); + die_if(message->used >= message->size, OUTPUT_OVERRUN_MSG); } void gdb_message_encode_int(struct gdb_message *message, uintptr_t val) { int length = sizeof(uintptr_t) * 2 - __builtin_clz(val) / 4; - die_if(message->used + length > message->size, output_overrun); + die_if(message->used + length > message->size, OUTPUT_OVERRUN_MSG); while (length--) message->buf[message->used++] = to_hex((val >> length * 4) & 0xf); |