Commit 7db6f5fb authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

vsprintf: Recursive vsnprintf: Add "%pV", struct va_format

Add the ability to print a format and va_list from a structure pointer

Allows __dev_printk to be implemented as a single printk while
minimizing string space duplication.

%pV should not be used without some mechanism to verify the
format and argument use ala __attribute__(format (printf(...))).
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e490c1de
...@@ -171,6 +171,11 @@ static inline void might_fault(void) ...@@ -171,6 +171,11 @@ static inline void might_fault(void)
} }
#endif #endif
struct va_format {
const char *fmt;
va_list *va;
};
extern struct atomic_notifier_head panic_notifier_list; extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time); extern long (*panic_blink)(long time);
NORET_TYPE void panic(const char * fmt, ...) NORET_TYPE void panic(const char * fmt, ...)
......
...@@ -980,6 +980,11 @@ char *uuid_string(char *buf, char *end, const u8 *addr, ...@@ -980,6 +980,11 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
* [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15] * [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15]
* little endian output byte order is: * little endian output byte order is:
* [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15] * [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15]
* - 'V' For a struct va_format which contains a format string * and va_list *,
* call vsnprintf(->format, *->va_list).
* Implements a "recursive vsnprintf".
* Do not use this feature without some mechanism to verify the
* correctness of the format string and va_list arguments.
* *
* Note: The difference between 'S' and 'F' is that on ia64 and ppc64 * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
* function pointers are really function descriptors, which contain a * function pointers are really function descriptors, which contain a
...@@ -1025,6 +1030,10 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, ...@@ -1025,6 +1030,10 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
break; break;
case 'U': case 'U':
return uuid_string(buf, end, ptr, spec, fmt); return uuid_string(buf, end, ptr, spec, fmt);
case 'V':
return buf + vsnprintf(buf, end - buf,
((struct va_format *)ptr)->fmt,
*(((struct va_format *)ptr)->va));
} }
spec.flags |= SMALL; spec.flags |= SMALL;
if (spec.field_width == -1) { if (spec.field_width == -1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment