Lines Matching refs:spec
458 struct printf_spec spec) in number() argument
464 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
467 int field_width = spec.field_width; in number()
468 int precision = spec.precision; in number()
472 locase = (spec.flags & SMALL); in number()
473 if (spec.flags & LEFT) in number()
474 spec.flags &= ~ZEROPAD; in number()
476 if (spec.flags & SIGN) { in number()
481 } else if (spec.flags & PLUS) { in number()
484 } else if (spec.flags & SPACE) { in number()
490 if (spec.base == 16) in number()
498 if (num < spec.base) in number()
500 else if (spec.base != 10) { /* 8 or 16 */ in number()
501 int mask = spec.base - 1; in number()
504 if (spec.base == 16) in number()
519 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
534 if (spec.base == 16 || !is_zero) { in number()
539 if (spec.base == 16) { in number()
546 if (!(spec.flags & LEFT)) { in number()
547 char c = ' ' + (spec.flags & ZEROPAD); in number()
580 struct printf_spec spec; in special_hex_number() local
582 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
583 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
584 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
585 spec.base = 16; in special_hex_number()
586 spec.precision = -1; in special_hex_number()
588 return number(buf, end, num, spec); in special_hex_number()
618 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
622 if (likely(n >= spec.field_width)) in widen_string()
625 spaces = spec.field_width - n; in widen_string()
626 if (!(spec.flags & LEFT)) { in widen_string()
640 struct printf_spec spec) in string_nocheck() argument
643 int lim = spec.precision; in string_nocheck()
654 return widen_string(buf, len, end, spec); in string_nocheck()
658 struct printf_spec spec) in err_ptr() argument
664 return string_nocheck(buf, end, sym, spec); in err_ptr()
671 spec.flags |= SIGN; in err_ptr()
672 spec.base = 10; in err_ptr()
673 return number(buf, end, err, spec); in err_ptr()
678 struct printf_spec spec) in error_string() argument
685 if (spec.precision == -1) in error_string()
686 spec.precision = 2 * sizeof(void *); in error_string()
688 return string_nocheck(buf, end, s, spec); in error_string()
708 struct printf_spec spec) in check_pointer() argument
714 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
723 struct printf_spec spec) in string() argument
725 if (check_pointer(&buf, end, s, spec)) in string()
728 return string_nocheck(buf, end, s, spec); in string()
733 struct printf_spec spec) in pointer_string() argument
735 spec.base = 16; in pointer_string()
736 spec.flags |= SMALL; in pointer_string()
737 if (spec.field_width == -1) { in pointer_string()
738 spec.field_width = 2 * sizeof(ptr); in pointer_string()
739 spec.flags |= ZEROPAD; in pointer_string()
742 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
808 struct printf_spec spec) in ptr_to_id() argument
819 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
824 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
829 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
831 return error_string(buf, end, str, spec); in ptr_to_id()
834 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
838 struct printf_spec spec) in default_pointer() argument
845 return pointer_string(buf, end, ptr, spec); in default_pointer()
847 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
854 struct printf_spec spec) in restricted_pointer() argument
859 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
868 if (spec.field_width == -1) in restricted_pointer()
869 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
870 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
896 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
900 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
918 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
933 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
945 return widen_string(buf, n, end, spec); in dentry_name()
950 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
952 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
955 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
960 struct printf_spec spec, const char *fmt) in bdev_name() argument
964 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
968 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
975 buf = number(buf, end, bdev_partno(bdev), spec); in bdev_name()
983 struct printf_spec spec, const char *fmt) in symbol_string() argument
1006 return string_nocheck(buf, end, sym, spec); in symbol_string()
1044 struct printf_spec spec, const char *fmt) in resource_string() argument
1090 if (check_pointer(&buf, end, res, spec)) in resource_string()
1140 return string_nocheck(buf, end, sym, spec); in resource_string()
1144 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1151 if (spec.field_width == 0) in hex_string()
1155 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1173 if (spec.field_width > 0) in hex_string()
1174 len = min_t(int, spec.field_width, 64); in hex_string()
1196 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1199 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1203 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1207 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1230 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1231 buf = number(buf, end, val, spec); in bitmap_string()
1240 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1242 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1246 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1270 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1278 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1306 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1460 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1469 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1474 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1480 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1485 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1529 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1534 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1538 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1542 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1547 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1573 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1577 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1582 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1586 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1591 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1593 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1603 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1605 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1607 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1612 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1616 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1624 if (spec.field_width == 0) in escaped_string()
1627 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1662 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1675 struct printf_spec spec, const char *fmt) in va_format() argument
1679 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1691 struct printf_spec spec, const char *fmt) in uuid_string() argument
1699 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1731 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1736 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1741 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1750 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1758 struct printf_spec spec, const char *fmt) in fourcc_string() argument
1766 return error_string(buf, end, "(%p4?)", spec); in fourcc_string()
1768 if (check_pointer(&buf, end, fourcc, spec)) in fourcc_string()
1791 return string(buf, end, output, spec); in fourcc_string()
1796 struct printf_spec spec, const char *fmt) in address_val() argument
1801 if (check_pointer(&buf, end, addr, spec)) in address_val()
1856 struct printf_spec spec, const char *fmt) in rtc_str() argument
1863 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1906 struct printf_spec spec, const char *fmt) in time64_str() argument
1924 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1928 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1933 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1935 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1937 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1942 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1946 return error_string(buf, end, "(%pC?)", spec); in clock()
1948 if (check_pointer(&buf, end, clk, spec)) in clock()
1955 return string(buf, end, __clk_get_name(clk), spec); in clock()
1957 return ptr_to_id(buf, end, clk, spec); in clock()
1993 const struct printf_spec *spec; member
2046 *pff[i].spec); in format_page_flags()
2059 struct printf_spec spec, const char *fmt) in flags_string() argument
2064 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
2079 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2114 struct printf_spec spec, const char *fmt) in device_node_string() argument
2123 struct printf_spec str_spec = spec; in device_node_string()
2127 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2130 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2132 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2199 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2204 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2206 struct printf_spec str_spec = spec; in fwnode_string()
2212 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2214 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2229 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2393 struct printf_spec spec) in pointer() argument
2401 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2404 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2406 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2410 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2412 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2418 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2428 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2430 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2432 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2434 return va_format(buf, end, ptr, spec, fmt); in pointer()
2436 return restricted_pointer(buf, end, ptr, spec); in pointer()
2438 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2440 return fourcc_string(buf, end, ptr, spec, fmt); in pointer()
2442 return address_val(buf, end, ptr, spec, fmt); in pointer()
2444 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2446 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2448 return clock(buf, end, ptr, spec, fmt); in pointer()
2450 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2453 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2457 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2459 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2461 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2465 return error_string(buf, end, "(%pA?)", spec); in pointer()
2469 return pointer_string(buf, end, ptr, spec); in pointer()
2473 return default_pointer(buf, end, ptr, spec); in pointer()
2474 return err_ptr(buf, end, ptr, spec); in pointer()
2479 return string(buf, end, ptr, spec); in pointer()
2481 return error_string(buf, end, "(einval)", spec); in pointer()
2484 return default_pointer(buf, end, ptr, spec); in pointer()
2510 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2516 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2517 if (spec->field_width < 0) { in format_decode()
2518 spec->field_width = -spec->field_width; in format_decode()
2519 spec->flags |= LEFT; in format_decode()
2521 spec->type = FORMAT_TYPE_NONE; in format_decode()
2526 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2527 if (spec->precision < 0) in format_decode()
2528 spec->precision = 0; in format_decode()
2530 spec->type = FORMAT_TYPE_NONE; in format_decode()
2535 spec->type = FORMAT_TYPE_NONE; in format_decode()
2547 spec->flags = 0; in format_decode()
2555 case '-': spec->flags |= LEFT; break; in format_decode()
2556 case '+': spec->flags |= PLUS; break; in format_decode()
2557 case ' ': spec->flags |= SPACE; break; in format_decode()
2558 case '#': spec->flags |= SPECIAL; break; in format_decode()
2559 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2568 spec->field_width = -1; in format_decode()
2571 spec->field_width = skip_atoi(&fmt); in format_decode()
2574 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2580 spec->precision = -1; in format_decode()
2584 spec->precision = skip_atoi(&fmt); in format_decode()
2585 if (spec->precision < 0) in format_decode()
2586 spec->precision = 0; in format_decode()
2589 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2612 spec->base = 10; in format_decode()
2615 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2619 spec->type = FORMAT_TYPE_STR; in format_decode()
2623 spec->type = FORMAT_TYPE_PTR; in format_decode()
2627 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2632 spec->base = 8; in format_decode()
2636 spec->flags |= SMALL; in format_decode()
2640 spec->base = 16; in format_decode()
2645 spec->flags |= SIGN; in format_decode()
2660 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2665 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2668 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2670 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2672 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2675 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2678 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2681 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2688 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2690 spec->field_width = width; in set_field_width()
2691 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2692 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2697 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2699 spec->precision = prec; in set_precision()
2700 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2701 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2737 struct printf_spec spec = {0}; in vsnprintf() local
2755 int read = format_decode(fmt, &spec); in vsnprintf()
2759 switch (spec.type) { in vsnprintf()
2772 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2776 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2782 if (!(spec.flags & LEFT)) { in vsnprintf()
2783 while (--spec.field_width > 0) { in vsnprintf()
2794 while (--spec.field_width > 0) { in vsnprintf()
2803 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2808 spec); in vsnprintf()
2831 switch (spec.type) { in vsnprintf()
2842 if (spec.flags & SIGN) in vsnprintf()
2869 str = number(str, end, num, spec); in vsnprintf()
3040 struct printf_spec spec = {0}; in vbin_printf() local
3072 int read = format_decode(fmt, &spec); in vbin_printf()
3076 switch (spec.type) { in vbin_printf()
3088 set_field_width(&spec, width); in vbin_printf()
3128 spec); in vbin_printf()
3140 switch (spec.type) { in vbin_printf()
3199 struct printf_spec spec = {0}; in bstr_printf() local
3232 int read = format_decode(fmt, &spec); in bstr_printf()
3236 switch (spec.type) { in bstr_printf()
3249 set_field_width(&spec, get_arg(int)); in bstr_printf()
3253 set_precision(&spec, get_arg(int)); in bstr_printf()
3259 if (!(spec.flags & LEFT)) { in bstr_printf()
3260 while (--spec.field_width > 0) { in bstr_printf()
3270 while (--spec.field_width > 0) { in bstr_printf()
3281 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3313 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3332 switch (spec.type) { in bstr_printf()
3366 str = number(str, end, num, spec); in bstr_printf()