Lines Matching full:spec
445 struct printf_spec spec) in number() argument
451 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
454 int field_width = spec.field_width; in number()
455 int precision = spec.precision; in number()
459 locase = (spec.flags & SMALL); in number()
460 if (spec.flags & LEFT) in number()
461 spec.flags &= ~ZEROPAD; in number()
463 if (spec.flags & SIGN) { in number()
468 } else if (spec.flags & PLUS) { in number()
471 } else if (spec.flags & SPACE) { in number()
477 if (spec.base == 16) in number()
485 if (num < spec.base) in number()
487 else if (spec.base != 10) { /* 8 or 16 */ in number()
488 int mask = spec.base - 1; in number()
491 if (spec.base == 16) in number()
506 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
521 if (spec.base == 16 || !is_zero) { in number()
526 if (spec.base == 16) { in number()
533 if (!(spec.flags & LEFT)) { in number()
534 char c = ' ' + (spec.flags & ZEROPAD); in number()
567 struct printf_spec spec; in special_hex_number() local
569 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
570 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
571 spec.base = 16; in special_hex_number()
572 spec.precision = -1; in special_hex_number()
574 return number(buf, end, num, spec); in special_hex_number()
600 * @spec: for field width and flags
604 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
608 if (likely(n >= spec.field_width)) in widen_string()
611 spaces = spec.field_width - n; in widen_string()
612 if (!(spec.flags & LEFT)) { in widen_string()
626 struct printf_spec spec) in string_nocheck() argument
629 int lim = spec.precision; in string_nocheck()
640 return widen_string(buf, len, end, spec); in string_nocheck()
644 struct printf_spec spec) in err_ptr() argument
650 return string_nocheck(buf, end, sym, spec); in err_ptr()
657 spec.flags |= SIGN; in err_ptr()
658 spec.base = 10; in err_ptr()
659 return number(buf, end, err, spec); in err_ptr()
664 struct printf_spec spec) in error_string() argument
671 if (spec.precision == -1) in error_string()
672 spec.precision = 2 * sizeof(void *); in error_string()
674 return string_nocheck(buf, end, s, spec); in error_string()
694 struct printf_spec spec) in check_pointer() argument
700 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
709 struct printf_spec spec) in string() argument
711 if (check_pointer(&buf, end, s, spec)) in string()
714 return string_nocheck(buf, end, s, spec); in string()
719 struct printf_spec spec) in pointer_string() argument
721 spec.base = 16; in pointer_string()
722 spec.flags |= SMALL; in pointer_string()
723 if (spec.field_width == -1) { in pointer_string()
724 spec.field_width = 2 * sizeof(ptr); in pointer_string()
725 spec.flags |= ZEROPAD; in pointer_string()
728 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
794 struct printf_spec spec) in ptr_to_id() argument
805 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
810 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
815 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
817 return error_string(buf, end, str, spec); in ptr_to_id()
820 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
824 struct printf_spec spec) in default_pointer() argument
831 return pointer_string(buf, end, ptr, spec); in default_pointer()
833 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
840 struct printf_spec spec) in restricted_pointer() argument
845 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
854 if (spec.field_width == -1) in restricted_pointer()
855 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
856 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
882 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
886 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
904 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
919 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
931 return widen_string(buf, n, end, spec); in dentry_name()
936 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
938 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
941 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
946 struct printf_spec spec, const char *fmt) in bdev_name() argument
950 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
954 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
961 buf = number(buf, end, bdev_partno(bdev), spec); in bdev_name()
969 struct printf_spec spec, const char *fmt) in symbol_string() argument
992 return string_nocheck(buf, end, sym, spec); in symbol_string()
1030 struct printf_spec spec) in hex_range() argument
1032 buf = number(buf, end, start_val, spec); in hex_range()
1039 return number(buf, end, end_val, spec); in hex_range()
1044 struct printf_spec spec, const char *fmt) in resource_string() argument
1090 if (check_pointer(&buf, end, res, spec)) in resource_string()
1136 return string_nocheck(buf, end, sym, spec); in resource_string()
1141 struct printf_spec spec, const char *fmt) in range_string() argument
1153 if (check_pointer(&buf, end, range, spec)) in range_string()
1161 return string_nocheck(buf, end, sym, spec); in range_string()
1165 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1172 if (spec.field_width == 0) in hex_string()
1176 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1194 if (spec.field_width > 0) in hex_string()
1195 len = min_t(int, spec.field_width, 64); in hex_string()
1217 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1220 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1224 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1228 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1251 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1252 buf = number(buf, end, val, spec); in bitmap_string()
1261 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1263 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1267 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1291 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1299 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1327 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1481 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1490 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1495 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1501 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1506 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1550 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1555 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1559 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1563 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1568 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1594 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1598 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1603 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1607 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1612 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1614 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1624 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1626 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1628 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1633 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1637 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1645 if (spec.field_width == 0) in escaped_string()
1648 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1683 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1696 struct printf_spec spec, const char *fmt) in va_format() argument
1700 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1712 struct printf_spec spec, const char *fmt) in uuid_string() argument
1720 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1752 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1757 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1762 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1771 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1779 struct printf_spec spec, const char *fmt) in fourcc_string() argument
1787 return error_string(buf, end, "(%p4?)", spec); in fourcc_string()
1789 if (check_pointer(&buf, end, fourcc, spec)) in fourcc_string()
1812 return string(buf, end, output, spec); in fourcc_string()
1817 struct printf_spec spec, const char *fmt) in address_val() argument
1822 if (check_pointer(&buf, end, addr, spec)) in address_val()
1877 struct printf_spec spec, const char *fmt) in rtc_str() argument
1884 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1927 struct printf_spec spec, const char *fmt) in time64_str() argument
1945 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1949 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1954 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1956 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1958 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1963 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1967 return error_string(buf, end, "(%pC?)", spec); in clock()
1969 if (check_pointer(&buf, end, clk, spec)) in clock()
1976 return string(buf, end, __clk_get_name(clk), spec); in clock()
1978 return ptr_to_id(buf, end, clk, spec); in clock()
2014 const struct printf_spec *spec; member
2067 *pff[i].spec); in format_page_flags()
2080 struct printf_spec spec, const char *fmt) in flags_string() argument
2085 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
2100 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2135 struct printf_spec spec, const char *fmt) in device_node_string() argument
2144 struct printf_spec str_spec = spec; in device_node_string()
2148 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2151 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2153 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2184 case 'P': /* path-spec */ in device_node_string()
2220 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2225 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2227 struct printf_spec str_spec = spec; in fwnode_string()
2233 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2235 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2250 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2255 struct printf_spec spec) in resource_or_range() argument
2258 return range_string(buf, end, ptr, spec, fmt); in resource_or_range()
2259 return resource_string(buf, end, ptr, spec, fmt); in resource_or_range()
2397 * P device node path spec (name + @unit)
2424 struct printf_spec spec) in pointer() argument
2432 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2435 return resource_or_range(fmt, buf, end, ptr, spec); in pointer()
2437 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2441 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2443 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2449 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2459 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2461 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2463 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2465 return va_format(buf, end, ptr, spec, fmt); in pointer()
2467 return restricted_pointer(buf, end, ptr, spec); in pointer()
2469 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2471 return fourcc_string(buf, end, ptr, spec, fmt); in pointer()
2473 return address_val(buf, end, ptr, spec, fmt); in pointer()
2475 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2477 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2479 return clock(buf, end, ptr, spec, fmt); in pointer()
2481 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2484 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2488 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2490 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2492 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2496 return error_string(buf, end, "(%pA?)", spec); in pointer()
2500 return pointer_string(buf, end, ptr, spec); in pointer()
2504 return default_pointer(buf, end, ptr, spec); in pointer()
2505 return err_ptr(buf, end, ptr, spec); in pointer()
2510 return string(buf, end, ptr, spec); in pointer()
2512 return error_string(buf, end, "(einval)", spec); in pointer()
2515 return default_pointer(buf, end, ptr, spec); in pointer()
2561 struct fmt format_decode(struct fmt fmt, struct printf_spec *spec) in format_decode() argument
2568 if (spec->field_width < 0) { in format_decode()
2569 spec->field_width = -spec->field_width; in format_decode()
2570 spec->flags |= LEFT; in format_decode()
2578 if (spec->precision < 0) in format_decode()
2579 spec->precision = 0; in format_decode()
2598 spec->flags = 0; in format_decode()
2602 spec->flags |= flag; in format_decode()
2606 spec->field_width = -1; in format_decode()
2609 spec->field_width = skip_atoi(&fmt.str); in format_decode()
2619 spec->precision = -1; in format_decode()
2623 spec->precision = skip_atoi(&fmt.str); in format_decode()
2624 if (spec->precision < 0) in format_decode()
2625 spec->precision = 0; in format_decode()
2636 spec->base = 10; in format_decode()
2686 spec->base = p->base; in format_decode()
2687 spec->flags |= p->flags_or_double_size; in format_decode()
2699 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2701 spec->field_width = width; in set_field_width()
2702 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2703 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2708 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2710 spec->precision = prec; in set_precision()
2711 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2712 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2722 static unsigned long long convert_num_spec(unsigned int val, int size, struct printf_spec spec) in convert_num_spec() argument
2727 if (!(spec.flags & SIGN)) in convert_num_spec()
2763 struct printf_spec spec = {0}; in vsnprintf() local
2786 fmt = format_decode(fmt, &spec); in vsnprintf()
2804 num = convert_num_spec(va_arg(args, int), fmt.size, spec); in vsnprintf()
2807 str = number(str, end, num, spec); in vsnprintf()
2812 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2816 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2822 if (!(spec.flags & LEFT)) { in vsnprintf()
2823 while (--spec.field_width > 0) { in vsnprintf()
2834 while (--spec.field_width > 0) { in vsnprintf()
2843 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2848 spec); in vsnprintf()
3043 struct printf_spec spec = {0}; in vbin_printf() local
3075 fmt = format_decode(fmt, &spec); in vbin_printf()
3089 set_field_width(&spec, width); in vbin_printf()
3129 spec); in vbin_printf()
3183 struct printf_spec spec = {0}; in bstr_printf() local
3218 fmt = format_decode(fmt, &spec); in bstr_printf()
3233 set_field_width(&spec, get_arg(int)); in bstr_printf()
3237 set_precision(&spec, get_arg(int)); in bstr_printf()
3243 if (!(spec.flags & LEFT)) { in bstr_printf()
3244 while (--spec.field_width > 0) { in bstr_printf()
3254 while (--spec.field_width > 0) { in bstr_printf()
3265 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3297 str = pointer(fmt.str, str, end, get_arg(void *), spec); in bstr_printf()
3317 num = convert_num_spec(get_arg(int), fmt.size, spec); in bstr_printf()
3319 str = number(str, end, num, spec); in bstr_printf()