Lines Matching refs:spec

452 	     struct printf_spec spec)  in number()  argument
458 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
461 int field_width = spec.field_width; in number()
462 int precision = spec.precision; in number()
466 locase = (spec.flags & SMALL); in number()
467 if (spec.flags & LEFT) in number()
468 spec.flags &= ~ZEROPAD; in number()
470 if (spec.flags & SIGN) { in number()
475 } else if (spec.flags & PLUS) { in number()
478 } else if (spec.flags & SPACE) { in number()
484 if (spec.base == 16) in number()
492 if (num < spec.base) in number()
494 else if (spec.base != 10) { /* 8 or 16 */ in number()
495 int mask = spec.base - 1; in number()
498 if (spec.base == 16) in number()
513 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
528 if (spec.base == 16 || !is_zero) { in number()
533 if (spec.base == 16) { in number()
540 if (!(spec.flags & LEFT)) { in number()
541 char c = ' ' + (spec.flags & ZEROPAD); in number()
574 struct printf_spec spec; in special_hex_number() local
576 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
577 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
578 spec.base = 16; in special_hex_number()
579 spec.precision = -1; in special_hex_number()
581 return number(buf, end, num, spec); in special_hex_number()
611 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
615 if (likely(n >= spec.field_width)) in widen_string()
618 spaces = spec.field_width - n; in widen_string()
619 if (!(spec.flags & LEFT)) { in widen_string()
633 struct printf_spec spec) in string_nocheck() argument
636 int lim = spec.precision; in string_nocheck()
647 return widen_string(buf, len, end, spec); in string_nocheck()
651 struct printf_spec spec) in err_ptr() argument
657 return string_nocheck(buf, end, sym, spec); in err_ptr()
664 spec.flags |= SIGN; in err_ptr()
665 spec.base = 10; in err_ptr()
666 return number(buf, end, err, spec); in err_ptr()
671 struct printf_spec spec) in error_string() argument
678 if (spec.precision == -1) in error_string()
679 spec.precision = 2 * sizeof(void *); in error_string()
681 return string_nocheck(buf, end, s, spec); in error_string()
701 struct printf_spec spec) in check_pointer() argument
707 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
716 struct printf_spec spec) in string() argument
718 if (check_pointer(&buf, end, s, spec)) in string()
721 return string_nocheck(buf, end, s, spec); in string()
726 struct printf_spec spec) in pointer_string() argument
728 spec.base = 16; in pointer_string()
729 spec.flags |= SMALL; in pointer_string()
730 if (spec.field_width == -1) { in pointer_string()
731 spec.field_width = 2 * sizeof(ptr); in pointer_string()
732 spec.flags |= ZEROPAD; in pointer_string()
735 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
801 struct printf_spec spec) in ptr_to_id() argument
812 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
817 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
822 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
824 return error_string(buf, end, str, spec); in ptr_to_id()
827 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
831 struct printf_spec spec) in default_pointer() argument
838 return pointer_string(buf, end, ptr, spec); in default_pointer()
840 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
847 struct printf_spec spec) in restricted_pointer() argument
852 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
861 if (spec.field_width == -1) in restricted_pointer()
862 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
863 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
889 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
893 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
911 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
926 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
938 return widen_string(buf, n, end, spec); in dentry_name()
943 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
945 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
948 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
953 struct printf_spec spec, const char *fmt) in bdev_name() argument
957 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
961 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
968 buf = number(buf, end, bdev_partno(bdev), spec); in bdev_name()
976 struct printf_spec spec, const char *fmt) in symbol_string() argument
999 return string_nocheck(buf, end, sym, spec); in symbol_string()
1037 struct printf_spec spec) in hex_range() argument
1039 buf = number(buf, end, start_val, spec); in hex_range()
1046 return number(buf, end, end_val, spec); in hex_range()
1051 struct printf_spec spec, const char *fmt) in resource_string() argument
1097 if (check_pointer(&buf, end, res, spec)) in resource_string()
1143 return string_nocheck(buf, end, sym, spec); in resource_string()
1148 struct printf_spec spec, const char *fmt) in range_string() argument
1160 if (check_pointer(&buf, end, range, spec)) in range_string()
1168 return string_nocheck(buf, end, sym, spec); in range_string()
1172 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1179 if (spec.field_width == 0) in hex_string()
1183 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1201 if (spec.field_width > 0) in hex_string()
1202 len = min_t(int, spec.field_width, 64); in hex_string()
1224 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1227 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1231 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1235 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1258 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1259 buf = number(buf, end, val, spec); in bitmap_string()
1268 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1270 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1274 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1298 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1306 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1334 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1488 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1497 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1502 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1508 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1513 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1557 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1562 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1566 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1570 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1575 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1601 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1605 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1610 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1614 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1619 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1621 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1631 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1633 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1635 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1640 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1644 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1652 if (spec.field_width == 0) in escaped_string()
1655 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1690 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1707 struct printf_spec spec) in va_format() argument
1711 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1724 struct printf_spec spec, const char *fmt) in uuid_string() argument
1732 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1764 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1769 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1774 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1783 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1791 struct printf_spec spec, const char *fmt) in fourcc_string() argument
1799 return error_string(buf, end, "(%p4?)", spec); in fourcc_string()
1801 if (check_pointer(&buf, end, fourcc, spec)) in fourcc_string()
1824 return string(buf, end, output, spec); in fourcc_string()
1829 struct printf_spec spec, const char *fmt) in address_val() argument
1834 if (check_pointer(&buf, end, addr, spec)) in address_val()
1889 struct printf_spec spec, const char *fmt) in rtc_str() argument
1896 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1939 struct printf_spec spec, const char *fmt) in time64_str() argument
1957 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1961 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1966 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1968 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1970 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1975 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1979 return error_string(buf, end, "(%pC?)", spec); in clock()
1981 if (check_pointer(&buf, end, clk, spec)) in clock()
1988 return string(buf, end, __clk_get_name(clk), spec); in clock()
1990 return ptr_to_id(buf, end, clk, spec); in clock()
2026 const struct printf_spec *spec; member
2079 *pff[i].spec); in format_page_flags()
2092 struct printf_spec spec, const char *fmt) in flags_string() argument
2097 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
2112 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2147 struct printf_spec spec, const char *fmt) in device_node_string() argument
2156 struct printf_spec str_spec = spec; in device_node_string()
2160 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2163 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2165 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2232 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2237 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2239 struct printf_spec str_spec = spec; in fwnode_string()
2245 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2247 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2262 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2267 struct printf_spec spec) in resource_or_range() argument
2270 return range_string(buf, end, ptr, spec, fmt); in resource_or_range()
2271 return resource_string(buf, end, ptr, spec, fmt); in resource_or_range()
2433 struct printf_spec spec) in pointer() argument
2441 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2444 return resource_or_range(fmt, buf, end, ptr, spec); in pointer()
2446 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2450 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2452 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2458 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2468 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2470 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2472 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2474 return va_format(buf, end, ptr, spec); in pointer()
2476 return restricted_pointer(buf, end, ptr, spec); in pointer()
2478 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2480 return fourcc_string(buf, end, ptr, spec, fmt); in pointer()
2482 return address_val(buf, end, ptr, spec, fmt); in pointer()
2484 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2486 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2488 return clock(buf, end, ptr, spec, fmt); in pointer()
2490 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2493 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2497 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2499 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2501 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2505 return error_string(buf, end, "(%pA?)", spec); in pointer()
2509 return pointer_string(buf, end, ptr, spec); in pointer()
2513 return default_pointer(buf, end, ptr, spec); in pointer()
2514 return err_ptr(buf, end, ptr, spec); in pointer()
2519 return string(buf, end, ptr, spec); in pointer()
2521 return error_string(buf, end, "(einval)", spec); in pointer()
2524 return default_pointer(buf, end, ptr, spec); in pointer()
2570 struct fmt format_decode(struct fmt fmt, struct printf_spec *spec) in format_decode() argument
2577 if (spec->field_width < 0) { in format_decode()
2578 spec->field_width = -spec->field_width; in format_decode()
2579 spec->flags |= LEFT; in format_decode()
2587 if (spec->precision < 0) in format_decode()
2588 spec->precision = 0; in format_decode()
2607 spec->flags = 0; in format_decode()
2611 spec->flags |= flag; in format_decode()
2615 spec->field_width = -1; in format_decode()
2618 spec->field_width = skip_atoi(&fmt.str); in format_decode()
2628 spec->precision = -1; in format_decode()
2632 spec->precision = skip_atoi(&fmt.str); in format_decode()
2633 if (spec->precision < 0) in format_decode()
2634 spec->precision = 0; in format_decode()
2645 spec->base = 10; in format_decode()
2695 spec->base = p->base; in format_decode()
2696 spec->flags |= p->flags_or_double_size; in format_decode()
2708 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2710 spec->field_width = width; in set_field_width()
2711 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2712 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2717 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2719 spec->precision = prec; in set_precision()
2720 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2721 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2731 static unsigned long long convert_num_spec(unsigned int val, int size, struct printf_spec spec) in convert_num_spec() argument
2736 if (!(spec.flags & SIGN)) in convert_num_spec()
2772 struct printf_spec spec = {0}; in vsnprintf() local
2795 fmt = format_decode(fmt, &spec); in vsnprintf()
2813 num = convert_num_spec(va_arg(args, int), fmt.size, spec); in vsnprintf()
2816 str = number(str, end, num, spec); in vsnprintf()
2821 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2825 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2831 if (!(spec.flags & LEFT)) { in vsnprintf()
2832 while (--spec.field_width > 0) { in vsnprintf()
2843 while (--spec.field_width > 0) { in vsnprintf()
2852 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2857 spec); in vsnprintf()
3052 struct printf_spec spec = {0}; in vbin_printf() local
3084 fmt = format_decode(fmt, &spec); in vbin_printf()
3098 set_field_width(&spec, width); in vbin_printf()
3138 spec); in vbin_printf()
3192 struct printf_spec spec = {0}; in bstr_printf() local
3227 fmt = format_decode(fmt, &spec); in bstr_printf()
3242 set_field_width(&spec, get_arg(int)); in bstr_printf()
3246 set_precision(&spec, get_arg(int)); in bstr_printf()
3252 if (!(spec.flags & LEFT)) { in bstr_printf()
3253 while (--spec.field_width > 0) { in bstr_printf()
3263 while (--spec.field_width > 0) { in bstr_printf()
3274 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3306 str = pointer(fmt.str, str, end, get_arg(void *), spec); in bstr_printf()
3326 num = convert_num_spec(get_arg(int), fmt.size, spec); in bstr_printf()
3328 str = number(str, end, num, spec); in bstr_printf()