Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Angel Pons | b706ab3 | 2020-04-02 23:48:09 +0200 | [diff] [blame] | 2 | |
Damien Roth | 4e7e987 | 2016-01-16 18:59:51 -0700 | [diff] [blame] | 3 | /* |
Damien Roth | 4e7e987 | 2016-01-16 18:59:51 -0700 | [diff] [blame] | 4 | * vtxprintf.c, originally from linux/lib/vsprintf.c |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Stefan Reinauer | 52fc6b1 | 2009-10-24 13:06:04 +0000 | [diff] [blame] | 7 | #include <console/vtxprintf.h> |
Joel Kitching | 393c71c | 2019-06-16 16:09:42 +0800 | [diff] [blame] | 8 | #include <ctype.h> |
Edward O'Callaghan | 0ddb826 | 2014-06-17 18:37:08 +1000 | [diff] [blame] | 9 | #include <string.h> |
Elyes HAOUAS | 826459d | 2021-02-11 20:28:22 +0100 | [diff] [blame] | 10 | #include <types.h> |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 11 | |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 12 | #define call_tx(x) tx_byte(x, data) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 13 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 14 | #define ZEROPAD 1 /* pad with zero */ |
| 15 | #define SIGN 2 /* unsigned/signed long */ |
| 16 | #define PLUS 4 /* show plus */ |
| 17 | #define SPACE 8 /* space if plus */ |
| 18 | #define LEFT 16 /* left justified */ |
| 19 | #define SPECIAL 32 /* 0x */ |
| 20 | #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ |
| 21 | |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 22 | static int number(void (*tx_byte)(unsigned char byte, void *data), unsigned long long inum, |
| 23 | int base, int size, int precision, int type, void *data) |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 24 | { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 25 | char c, sign, tmp[66]; |
Jacob Garber | b19946c | 2019-07-03 14:40:11 -0600 | [diff] [blame] | 26 | const char *digits = "0123456789abcdef"; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 27 | int i; |
| 28 | int count = 0; |
Vadim Bendebury | 9b058467 | 2014-11-29 22:05:09 -0800 | [diff] [blame] | 29 | unsigned long long num = inum; |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 30 | long long snum = num; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 31 | |
| 32 | if (type & LARGE) |
Jacob Garber | b19946c | 2019-07-03 14:40:11 -0600 | [diff] [blame] | 33 | digits = "0123456789ABCDEF"; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 34 | if (type & LEFT) |
| 35 | type &= ~ZEROPAD; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 36 | c = (type & ZEROPAD) ? '0' : ' '; |
| 37 | sign = 0; |
| 38 | if (type & SIGN) { |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 39 | if (snum < 0) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 40 | sign = '-'; |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 41 | num = -snum; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 42 | size--; |
| 43 | } else if (type & PLUS) { |
| 44 | sign = '+'; |
| 45 | size--; |
| 46 | } else if (type & SPACE) { |
| 47 | sign = ' '; |
| 48 | size--; |
| 49 | } |
| 50 | } |
| 51 | if (type & SPECIAL) { |
| 52 | if (base == 16) |
| 53 | size -= 2; |
| 54 | else if (base == 8) |
| 55 | size--; |
| 56 | } |
| 57 | i = 0; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 58 | if (num == 0) { |
| 59 | tmp[i++] = '0'; |
| 60 | } else { |
| 61 | while (num != 0) { |
| 62 | tmp[i++] = digits[num % base]; |
| 63 | num /= base; |
| 64 | } |
Ronald G. Minnich | 79e36d9 | 2013-01-30 14:29:34 -0800 | [diff] [blame] | 65 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 66 | if (i > precision) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 67 | precision = i; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 68 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 69 | size -= precision; |
Elyes Haouas | 23f2729 | 2022-09-13 08:54:49 +0200 | [diff] [blame] | 70 | if (!(type & (ZEROPAD | LEFT))) { |
Elyes HAOUAS | 2e0f3d7 | 2018-05-03 09:36:28 +0200 | [diff] [blame] | 71 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 72 | call_tx(' '), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 73 | } |
| 74 | if (sign) { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 75 | call_tx(sign), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 76 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 77 | if (type & SPECIAL) { |
Elyes HAOUAS | 20767ba | 2018-04-26 10:00:35 +0200 | [diff] [blame] | 78 | if (base == 8) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 79 | call_tx('0'), count++; |
Elyes HAOUAS | 20767ba | 2018-04-26 10:00:35 +0200 | [diff] [blame] | 80 | else if (base == 16) { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 81 | call_tx('0'), count++; |
Jacob Garber | 5b99481 | 2019-07-10 11:44:45 -0600 | [diff] [blame] | 82 | if (type & LARGE) |
| 83 | call_tx('X'), count++; |
| 84 | else |
| 85 | call_tx('x'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 86 | } |
| 87 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 88 | if (!(type & LEFT)) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 89 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 90 | call_tx(c), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 91 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 92 | while (i < precision--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 93 | call_tx('0'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 94 | while (i-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 95 | call_tx(tmp[i]), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 96 | while (size-- > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 97 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 98 | return count; |
| 99 | } |
| 100 | |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 101 | int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), const char *fmt, va_list args, |
| 102 | void *data) |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 103 | { |
| 104 | int len; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 105 | unsigned long long num; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 106 | int i, base; |
| 107 | const char *s; |
| 108 | |
| 109 | int flags; /* flags to number() */ |
| 110 | |
| 111 | int field_width; /* width of output field */ |
| 112 | int precision; /* min. # of digits for integers; max |
| 113 | number of chars for from string */ |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 114 | int qualifier; /* 'h', 'H', 'l', 'L', 'z', or 'j' for integer fields */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 115 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 116 | int count; |
| 117 | |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 118 | for (count = 0; *fmt; ++fmt) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 119 | if (*fmt != '%') { |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 120 | call_tx(*fmt), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 121 | continue; |
| 122 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 123 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 124 | /* process flags */ |
| 125 | flags = 0; |
Patrick Georgi | c5fc7db | 2012-03-07 15:55:47 +0100 | [diff] [blame] | 126 | repeat: |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 127 | ++fmt; /* this also skips first '%' */ |
| 128 | switch (*fmt) { |
| 129 | case '-': flags |= LEFT; goto repeat; |
| 130 | case '+': flags |= PLUS; goto repeat; |
| 131 | case ' ': flags |= SPACE; goto repeat; |
| 132 | case '#': flags |= SPECIAL; goto repeat; |
| 133 | case '0': flags |= ZEROPAD; goto repeat; |
| 134 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 135 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 136 | /* get field width */ |
| 137 | field_width = -1; |
Julius Werner | 66c77c2 | 2019-05-13 17:45:27 -0700 | [diff] [blame] | 138 | if (isdigit(*fmt)) { |
| 139 | field_width = skip_atoi((char **)&fmt); |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 140 | } else if (*fmt == '*') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 141 | ++fmt; |
| 142 | /* it's the next argument */ |
| 143 | field_width = va_arg(args, int); |
| 144 | if (field_width < 0) { |
| 145 | field_width = -field_width; |
| 146 | flags |= LEFT; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* get the precision */ |
| 151 | precision = -1; |
| 152 | if (*fmt == '.') { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 153 | ++fmt; |
Julius Werner | 66c77c2 | 2019-05-13 17:45:27 -0700 | [diff] [blame] | 154 | if (isdigit(*fmt)) { |
| 155 | precision = skip_atoi((char **)&fmt); |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 156 | } else if (*fmt == '*') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 157 | ++fmt; |
| 158 | /* it's the next argument */ |
| 159 | precision = va_arg(args, int); |
| 160 | } |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 161 | if (precision < 0) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 162 | precision = 0; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 163 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /* get the conversion qualifier */ |
| 167 | qualifier = -1; |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 168 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'z' || *fmt == 'j') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 169 | qualifier = *fmt; |
| 170 | ++fmt; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 171 | if (*fmt == 'l') { |
| 172 | qualifier = 'L'; |
| 173 | ++fmt; |
| 174 | } |
Patrick Georgi | d01ed75 | 2014-01-18 16:56:36 +0100 | [diff] [blame] | 175 | if (*fmt == 'h') { |
| 176 | qualifier = 'H'; |
| 177 | ++fmt; |
| 178 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | /* default base */ |
| 182 | base = 10; |
| 183 | |
| 184 | switch (*fmt) { |
| 185 | case 'c': |
| 186 | if (!(flags & LEFT)) |
| 187 | while (--field_width > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 188 | call_tx(' '), count++; |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 189 | call_tx((unsigned char)va_arg(args, int)), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 190 | while (--field_width > 0) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 191 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 192 | continue; |
| 193 | |
| 194 | case 's': |
| 195 | s = va_arg(args, char *); |
| 196 | if (!s) |
| 197 | s = "<NULL>"; |
| 198 | |
Martin Roth | ad6c885 | 2016-11-18 11:35:01 -0700 | [diff] [blame] | 199 | len = strnlen(s, (size_t)precision); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 200 | |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 201 | if (!(flags & LEFT)) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 202 | while (len < field_width--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 203 | call_tx(' '), count++; |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 204 | } |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 205 | for (i = 0; i < len; ++i) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 206 | call_tx(*s++), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 207 | while (len < field_width--) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 208 | call_tx(' '), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 209 | continue; |
| 210 | |
| 211 | case 'p': |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 212 | /* even on 64-bit systems, coreboot only resides in the |
| 213 | low 4GB so pad pointers to 32-bit for readability. */ |
| 214 | if (field_width == -1 && precision == -1) |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 215 | precision = 2 * sizeof(uint32_t); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 216 | flags |= SPECIAL; |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 217 | count += number(tx_byte, (unsigned long)va_arg(args, void *), 16, |
| 218 | field_width, precision, flags, data); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 219 | continue; |
| 220 | |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 221 | case 'n': |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 222 | if (qualifier == 'L') { |
| 223 | long long *ip = va_arg(args, long long *); |
| 224 | *ip = count; |
| 225 | } else if (qualifier == 'l') { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 226 | long *ip = va_arg(args, long *); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 227 | *ip = count; |
| 228 | } else { |
Elyes HAOUAS | a418414 | 2018-05-15 20:57:01 +0200 | [diff] [blame] | 229 | int *ip = va_arg(args, int *); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 230 | *ip = count; |
| 231 | } |
| 232 | continue; |
| 233 | |
| 234 | case '%': |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 235 | call_tx('%'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 236 | continue; |
| 237 | |
| 238 | /* integer number formats - set up the flags and "break" */ |
| 239 | case 'o': |
| 240 | base = 8; |
| 241 | break; |
| 242 | |
| 243 | case 'X': |
| 244 | flags |= LARGE; |
Arthur Heymans | fff2021 | 2021-03-15 14:56:16 +0100 | [diff] [blame] | 245 | __fallthrough; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 246 | case 'x': |
| 247 | base = 16; |
| 248 | break; |
| 249 | |
| 250 | case 'd': |
| 251 | case 'i': |
| 252 | flags |= SIGN; |
Arthur Heymans | fff2021 | 2021-03-15 14:56:16 +0100 | [diff] [blame] | 253 | __fallthrough; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 254 | case 'u': |
| 255 | break; |
| 256 | |
| 257 | default: |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 258 | call_tx('%'), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 259 | if (*fmt) |
Vladimir Serbinenko | f421b33 | 2013-11-26 21:43:05 +0100 | [diff] [blame] | 260 | call_tx(*fmt), count++; |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 261 | else |
| 262 | --fmt; |
| 263 | continue; |
| 264 | } |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 265 | if (qualifier == 'L') { |
| 266 | num = va_arg(args, unsigned long long); |
| 267 | } else if (qualifier == 'l') { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 268 | num = va_arg(args, unsigned long); |
Stefan Reinauer | bfff6de | 2012-05-15 13:28:07 -0700 | [diff] [blame] | 269 | } else if (qualifier == 'z') { |
| 270 | num = va_arg(args, size_t); |
Jacob Garber | c764fb2 | 2019-07-03 12:38:46 -0600 | [diff] [blame] | 271 | } else if (qualifier == 'j') { |
| 272 | num = va_arg(args, uintmax_t); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 273 | } else if (qualifier == 'h') { |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 274 | num = (unsigned short)va_arg(args, int); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 275 | if (flags & SIGN) |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 276 | num = (short)num; |
Patrick Georgi | d01ed75 | 2014-01-18 16:56:36 +0100 | [diff] [blame] | 277 | } else if (qualifier == 'H') { |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 278 | num = (unsigned char)va_arg(args, int); |
Patrick Georgi | d01ed75 | 2014-01-18 16:56:36 +0100 | [diff] [blame] | 279 | if (flags & SIGN) |
Elyes Haouas | d0033e3 | 2022-05-29 15:34:41 +0200 | [diff] [blame] | 280 | num = (signed char)num; |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 281 | } else if (flags & SIGN) { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 282 | num = va_arg(args, int); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 283 | } else { |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 284 | num = va_arg(args, unsigned int); |
Eric Biederman | f3ed1cf | 2004-10-16 08:38:58 +0000 | [diff] [blame] | 285 | } |
Kyösti Mälkki | b04e0ff | 2014-02-04 14:28:17 +0200 | [diff] [blame] | 286 | count += number(tx_byte, num, base, field_width, precision, flags, data); |
Stefan Reinauer | 34e3a14 | 2004-05-28 15:07:03 +0000 | [diff] [blame] | 287 | } |
| 288 | return count; |
| 289 | } |