Skip to content

Commit 2629760

Browse files
JoePerchestorvalds
authored andcommitted
vsprintf: neaten %pK kptr_restrict, save a bit of code space
If kptr restrictions are on, just set the passed pointer to NULL. $ size lib/vsprintf.o.* text data bss dec hex filename 8247 4 2 8253 203d lib/vsprintf.o.new 8282 4 2 8288 2060 lib/vsprintf.o.old Signed-off-by: Joe Perches <[email protected]> Cc: Dan Rosenberg <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3bb598f commit 2629760

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/vsprintf.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,16 +1047,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
10471047
if (spec.field_width == -1)
10481048
spec.field_width = 2 * sizeof(void *);
10491049
return string(buf, end, "pK-error", spec);
1050-
} else if ((kptr_restrict == 0) ||
1051-
(kptr_restrict == 1 &&
1052-
has_capability_noaudit(current, CAP_SYSLOG)))
1053-
break;
1054-
1055-
if (spec.field_width == -1) {
1056-
spec.field_width = 2 * sizeof(void *);
1057-
spec.flags |= ZEROPAD;
10581050
}
1059-
return number(buf, end, 0, spec);
1051+
if (!((kptr_restrict == 0) ||
1052+
(kptr_restrict == 1 &&
1053+
has_capability_noaudit(current, CAP_SYSLOG))))
1054+
ptr = NULL;
1055+
break;
10601056
}
10611057
spec.flags |= SMALL;
10621058
if (spec.field_width == -1) {

0 commit comments

Comments
 (0)