summaryrefslogtreecommitdiff
path: root/lib/libc/printf.c
diff options
context:
space:
mode:
authorClaus Pedersen <claustbp@google.com>2022-09-12 22:42:58 +0000
committerAndré Przywara <andre.przywara@arm.com>2022-09-22 13:23:49 +0200
commit885e26830499284a7718f825579d6ebeb8b6cd89 (patch)
tree88d41830192adc771cf3c0bbd9662a61a5260843 /lib/libc/printf.c
parent93910a74873cdd28fe9e25a9492993431bc90329 (diff)
downloadarm-trusted-firmware-885e26830499284a7718f825579d6ebeb8b6cd89.tar.gz
refactor(libc): clean up dependencies in libc
- Removing platform dependencies from libc modules. - Replacing panicking with actual error handling. - Debug macros are included indirectly from assert.h. Removing "platform_def.h" from assert.h and adding "common/debug.h" where the macros are used. - Removing hack for fixing PLAT_LOG_LEVEL_ASSERT to 40. Instead removing assert with expression, as this does not provide additional information. Signed-off-by: Claus Pedersen <claustbp@google.com> Change-Id: Icc201ea7b63c1277e423c1cfd13fd6816c2bc568
Diffstat (limited to 'lib/libc/printf.c')
-rw-r--r--lib/libc/printf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/printf.c b/lib/libc/printf.c
index 45e153ec7..0def148b7 100644
--- a/lib/libc/printf.c
+++ b/lib/libc/printf.c
@@ -9,8 +9,6 @@
#include <stdbool.h>
#include <stdint.h>
-#include <common/debug.h>
-
#define get_num_va_args(_args, _lcount) \
(((_lcount) > 1) ? va_arg(_args, long long int) : \
(((_lcount) == 1) ? va_arg(_args, long int) : \
@@ -43,6 +41,12 @@ static int unsigned_num_print(unsigned long long int unum, unsigned int radix,
int i = 0, count = 0;
unsigned int rem;
+ /* num_buf is only large enough for radix >= 10 */
+ if (radix < 10) {
+ assert(0);
+ return 0;
+ }
+
do {
rem = unum % radix;
if (rem < 0xa)