Lines Matching refs:spec
455 struct printf_spec spec) in number() argument
461 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
464 int field_width = spec.field_width; in number()
465 int precision = spec.precision; in number()
469 locase = (spec.flags & SMALL); in number()
470 if (spec.flags & LEFT) in number()
471 spec.flags &= ~ZEROPAD; in number()
473 if (spec.flags & SIGN) { in number()
478 } else if (spec.flags & PLUS) { in number()
481 } else if (spec.flags & SPACE) { in number()
487 if (spec.base == 16) in number()
495 if (num < spec.base) in number()
497 else if (spec.base != 10) { /* 8 or 16 */ in number()
498 int mask = spec.base - 1; in number()
501 if (spec.base == 16) in number()
516 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
531 if (spec.base == 16 || !is_zero) { in number()
536 if (spec.base == 16) { in number()
543 if (!(spec.flags & LEFT)) { in number()
544 char c = ' ' + (spec.flags & ZEROPAD); in number()
577 struct printf_spec spec; in special_hex_number() local
579 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
580 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
581 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
582 spec.base = 16; in special_hex_number()
583 spec.precision = -1; in special_hex_number()
585 return number(buf, end, num, spec); in special_hex_number()
615 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
619 if (likely(n >= spec.field_width)) in widen_string()
622 spaces = spec.field_width - n; in widen_string()
623 if (!(spec.flags & LEFT)) { in widen_string()
637 struct printf_spec spec) in string_nocheck() argument
640 int lim = spec.precision; in string_nocheck()
651 return widen_string(buf, len, end, spec); in string_nocheck()
655 struct printf_spec spec) in err_ptr() argument
661 return string_nocheck(buf, end, sym, spec); in err_ptr()
668 spec.flags |= SIGN; in err_ptr()
669 spec.base = 10; in err_ptr()
670 return number(buf, end, err, spec); in err_ptr()
675 struct printf_spec spec) in error_string() argument
682 if (spec.precision == -1) in error_string()
683 spec.precision = 2 * sizeof(void *); in error_string()
685 return string_nocheck(buf, end, s, spec); in error_string()
705 struct printf_spec spec) in check_pointer() argument
711 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
720 struct printf_spec spec) in string() argument
722 if (check_pointer(&buf, end, s, spec)) in string()
725 return string_nocheck(buf, end, s, spec); in string()
730 struct printf_spec spec) in pointer_string() argument
732 spec.base = 16; in pointer_string()
733 spec.flags |= SMALL; in pointer_string()
734 if (spec.field_width == -1) { in pointer_string()
735 spec.field_width = 2 * sizeof(ptr); in pointer_string()
736 spec.flags |= ZEROPAD; in pointer_string()
739 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
810 struct printf_spec spec) in ptr_to_id() argument
821 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
826 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
831 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
833 return error_string(buf, end, str, spec); in ptr_to_id()
836 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
840 struct printf_spec spec) in default_pointer() argument
847 return pointer_string(buf, end, ptr, spec); in default_pointer()
849 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
856 struct printf_spec spec) in restricted_pointer() argument
861 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
870 if (spec.field_width == -1) in restricted_pointer()
871 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
872 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
898 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
902 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
920 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
935 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
947 return widen_string(buf, n, end, spec); in dentry_name()
952 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
954 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
957 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
962 struct printf_spec spec, const char *fmt) in bdev_name() argument
966 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
970 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
977 buf = number(buf, end, bdev->bd_partno, spec); in bdev_name()
985 struct printf_spec spec, const char *fmt) in symbol_string() argument
1008 return string_nocheck(buf, end, sym, spec); in symbol_string()
1046 struct printf_spec spec, const char *fmt) in resource_string() argument
1092 if (check_pointer(&buf, end, res, spec)) in resource_string()
1142 return string_nocheck(buf, end, sym, spec); in resource_string()
1146 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1153 if (spec.field_width == 0) in hex_string()
1157 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1175 if (spec.field_width > 0) in hex_string()
1176 len = min_t(int, spec.field_width, 64); in hex_string()
1198 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1201 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1205 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1209 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1232 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1233 buf = number(buf, end, val, spec); in bitmap_string()
1242 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1244 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1248 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1272 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1280 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1308 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1462 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1471 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1476 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1482 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1487 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1531 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1536 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1540 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1544 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1549 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1575 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1579 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1584 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1588 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1593 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1595 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1605 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1607 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1609 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1614 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1618 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1626 if (spec.field_width == 0) in escaped_string()
1629 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1664 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1677 struct printf_spec spec, const char *fmt) in va_format() argument
1681 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1693 struct printf_spec spec, const char *fmt) in uuid_string() argument
1701 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1733 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1738 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1743 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1752 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1760 struct printf_spec spec, const char *fmt) in fourcc_string() argument
1768 return error_string(buf, end, "(%p4?)", spec); in fourcc_string()
1770 if (check_pointer(&buf, end, fourcc, spec)) in fourcc_string()
1793 return string(buf, end, output, spec); in fourcc_string()
1798 struct printf_spec spec, const char *fmt) in address_val() argument
1803 if (check_pointer(&buf, end, addr, spec)) in address_val()
1858 struct printf_spec spec, const char *fmt) in rtc_str() argument
1865 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1908 struct printf_spec spec, const char *fmt) in time64_str() argument
1926 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1930 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1935 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1937 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1939 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1944 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1948 return error_string(buf, end, "(%pC?)", spec); in clock()
1950 if (check_pointer(&buf, end, clk, spec)) in clock()
1957 return string(buf, end, __clk_get_name(clk), spec); in clock()
1959 return ptr_to_id(buf, end, clk, spec); in clock()
1995 const struct printf_spec *spec; member
2048 *pff[i].spec); in format_page_flags()
2061 struct printf_spec spec, const char *fmt) in flags_string() argument
2066 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
2081 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2111 struct printf_spec spec, const char *fmt) in device_node_string() argument
2120 struct printf_spec str_spec = spec; in device_node_string()
2124 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2127 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2129 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2196 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2201 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2203 struct printf_spec str_spec = spec; in fwnode_string()
2209 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2211 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2226 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2390 struct printf_spec spec) in pointer() argument
2398 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2401 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2403 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2407 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2409 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2415 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2425 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2427 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2429 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2431 return va_format(buf, end, ptr, spec, fmt); in pointer()
2433 return restricted_pointer(buf, end, ptr, spec); in pointer()
2435 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2437 return fourcc_string(buf, end, ptr, spec, fmt); in pointer()
2439 return address_val(buf, end, ptr, spec, fmt); in pointer()
2441 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2443 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2445 return clock(buf, end, ptr, spec, fmt); in pointer()
2447 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2450 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2454 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2456 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2458 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2462 return error_string(buf, end, "(%pA?)", spec); in pointer()
2466 return pointer_string(buf, end, ptr, spec); in pointer()
2470 return default_pointer(buf, end, ptr, spec); in pointer()
2471 return err_ptr(buf, end, ptr, spec); in pointer()
2476 return string(buf, end, ptr, spec); in pointer()
2478 return error_string(buf, end, "(einval)", spec); in pointer()
2481 return default_pointer(buf, end, ptr, spec); in pointer()
2507 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2513 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2514 if (spec->field_width < 0) { in format_decode()
2515 spec->field_width = -spec->field_width; in format_decode()
2516 spec->flags |= LEFT; in format_decode()
2518 spec->type = FORMAT_TYPE_NONE; in format_decode()
2523 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2524 if (spec->precision < 0) in format_decode()
2525 spec->precision = 0; in format_decode()
2527 spec->type = FORMAT_TYPE_NONE; in format_decode()
2532 spec->type = FORMAT_TYPE_NONE; in format_decode()
2544 spec->flags = 0; in format_decode()
2552 case '-': spec->flags |= LEFT; break; in format_decode()
2553 case '+': spec->flags |= PLUS; break; in format_decode()
2554 case ' ': spec->flags |= SPACE; break; in format_decode()
2555 case '#': spec->flags |= SPECIAL; break; in format_decode()
2556 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2565 spec->field_width = -1; in format_decode()
2568 spec->field_width = skip_atoi(&fmt); in format_decode()
2571 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2577 spec->precision = -1; in format_decode()
2581 spec->precision = skip_atoi(&fmt); in format_decode()
2582 if (spec->precision < 0) in format_decode()
2583 spec->precision = 0; in format_decode()
2586 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2609 spec->base = 10; in format_decode()
2612 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2616 spec->type = FORMAT_TYPE_STR; in format_decode()
2620 spec->type = FORMAT_TYPE_PTR; in format_decode()
2624 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2629 spec->base = 8; in format_decode()
2633 spec->flags |= SMALL; in format_decode()
2637 spec->base = 16; in format_decode()
2642 spec->flags |= SIGN; in format_decode()
2657 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2662 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2665 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2667 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2669 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2672 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2675 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2678 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2685 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2687 spec->field_width = width; in set_field_width()
2688 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2689 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2694 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2696 spec->precision = prec; in set_precision()
2697 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2698 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2734 struct printf_spec spec = {0}; in vsnprintf() local
2752 int read = format_decode(fmt, &spec); in vsnprintf()
2756 switch (spec.type) { in vsnprintf()
2769 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2773 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2779 if (!(spec.flags & LEFT)) { in vsnprintf()
2780 while (--spec.field_width > 0) { in vsnprintf()
2791 while (--spec.field_width > 0) { in vsnprintf()
2800 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2805 spec); in vsnprintf()
2828 switch (spec.type) { in vsnprintf()
2839 if (spec.flags & SIGN) in vsnprintf()
2866 str = number(str, end, num, spec); in vsnprintf()
3037 struct printf_spec spec = {0}; in vbin_printf() local
3069 int read = format_decode(fmt, &spec); in vbin_printf()
3073 switch (spec.type) { in vbin_printf()
3085 set_field_width(&spec, width); in vbin_printf()
3125 spec); in vbin_printf()
3137 switch (spec.type) { in vbin_printf()
3196 struct printf_spec spec = {0}; in bstr_printf() local
3229 int read = format_decode(fmt, &spec); in bstr_printf()
3233 switch (spec.type) { in bstr_printf()
3246 set_field_width(&spec, get_arg(int)); in bstr_printf()
3250 set_precision(&spec, get_arg(int)); in bstr_printf()
3256 if (!(spec.flags & LEFT)) { in bstr_printf()
3257 while (--spec.field_width > 0) { in bstr_printf()
3267 while (--spec.field_width > 0) { in bstr_printf()
3278 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3310 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3329 switch (spec.type) { in bstr_printf()
3363 str = number(str, end, num, spec); in bstr_printf()