summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-12-19 11:42:15 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2024-12-23 11:18:35 -0800
commit2b76e39fca4739a75c9a4f96f3471af6b1c18d9e (patch)
tree1e935a02baa6248c835ed72c804396434ffc4287 /lib/vsprintf.c
parentf372b2256acbfbbf703cfdfae3d02c5a6c0e1679 (diff)
vsnprintf: mark the indirect width and precision cases unlikely
Make the format_decode() code generation easier to look at by getting the strange and unlikely cases out of line. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 617b629c7373..31dca7b8ad90 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2568,7 +2568,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
char flag;
/* we finished early by reading the field width */
- if (fmt.state == FORMAT_STATE_WIDTH) {
+ if (unlikely(fmt.state == FORMAT_STATE_WIDTH)) {
if (spec->field_width < 0) {
spec->field_width = -spec->field_width;
spec->flags |= LEFT;
@@ -2578,7 +2578,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
}
/* we finished early by reading the precision */
- if (fmt.state == FORMAT_STATE_PRECISION) {
+ if (unlikely(fmt.state == FORMAT_STATE_PRECISION)) {
if (spec->precision < 0)
spec->precision = 0;
@@ -2611,7 +2611,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
if (isdigit(*fmt.str))
spec->field_width = skip_atoi(&fmt.str);
- else if (*fmt.str == '*') {
+ else if (unlikely(*fmt.str == '*')) {
/* it's the next argument */
fmt.state = FORMAT_STATE_WIDTH;
fmt.str++;
@@ -2621,7 +2621,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
precision:
/* get the precision */
spec->precision = -1;
- if (*fmt.str == '.') {
+ if (unlikely(*fmt.str == '.')) {
fmt.str++;
if (isdigit(*fmt.str)) {
spec->precision = skip_atoi(&fmt.str);