%#lp results in the address being prefixed with 0x, like %#p, but not if the capability is null-derived. Make sure the prefix is used in all cases.
Fixes: ("lib/vsprintf: Add support for architectural capabilities") Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com ---
This is probably the result of some confusion during the review process for the original patch, as the first version never printed the prefix.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/printk_...
lib/vsprintf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 0b551cf89880..1a2a01843775 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2550,13 +2550,9 @@ char *capability(const char *fmt, char *buf, char *end, void * __capability cap, * Same applies when hashing is active. */ if ((!cheri_tag_get(cap) && !__builtin_cheri_copy_from_high(cap)) || - (likely(!no_hash_pointers) && *fmt != 'x')) { - - /* Avoid adding prefix */ - spec.flags &= ~SPECIAL; + (likely(!no_hash_pointers) && *fmt != 'x')) return pointer(fmt, buf, end, (void *)cheri_address_get(cap), spec); - }
if (spec.flags & SPECIAL) { /* Simplified format for capabilities */ int orig_field_width = spec.field_width;