Lines Matching full:spec

423 	     struct printf_spec spec)  in number()  argument
429 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
432 int field_width = spec.field_width; in number()
433 int precision = spec.precision; in number()
437 locase = (spec.flags & SMALL); in number()
438 if (spec.flags & LEFT) in number()
439 spec.flags &= ~ZEROPAD; in number()
441 if (spec.flags & SIGN) { in number()
446 } else if (spec.flags & PLUS) { in number()
449 } else if (spec.flags & SPACE) { in number()
455 if (spec.base == 16) in number()
463 if (num < spec.base) in number()
465 else if (spec.base != 10) { /* 8 or 16 */ in number()
466 int mask = spec.base - 1; in number()
469 if (spec.base == 16) in number()
484 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
499 if (spec.base == 16 || !is_zero) { in number()
504 if (spec.base == 16) { in number()
511 if (!(spec.flags & LEFT)) { in number()
512 char c = ' ' + (spec.flags & ZEROPAD); in number()
545 struct printf_spec spec; in special_hex_number() local
547 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
548 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
549 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
550 spec.base = 16; in special_hex_number()
551 spec.precision = -1; in special_hex_number()
553 return number(buf, end, num, spec); in special_hex_number()
579 * @spec: for field width and flags
583 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
587 if (likely(n >= spec.field_width)) in widen_string()
590 spaces = spec.field_width - n; in widen_string()
591 if (!(spec.flags & LEFT)) { in widen_string()
605 struct printf_spec spec) in string_nocheck() argument
608 int lim = spec.precision; in string_nocheck()
619 return widen_string(buf, len, end, spec); in string_nocheck()
623 struct printf_spec spec) in err_ptr() argument
629 return string_nocheck(buf, end, sym, spec); in err_ptr()
636 spec.flags |= SIGN; in err_ptr()
637 spec.base = 10; in err_ptr()
638 return number(buf, end, err, spec); in err_ptr()
643 struct printf_spec spec) in error_string() argument
650 if (spec.precision == -1) in error_string()
651 spec.precision = 2 * sizeof(void *); in error_string()
653 return string_nocheck(buf, end, s, spec); in error_string()
673 struct printf_spec spec) in check_pointer() argument
679 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
688 struct printf_spec spec) in string() argument
690 if (check_pointer(&buf, end, s, spec)) in string()
693 return string_nocheck(buf, end, s, spec); in string()
698 struct printf_spec spec) in pointer_string() argument
700 spec.base = 16; in pointer_string()
701 spec.flags |= SMALL; in pointer_string()
702 if (spec.field_width == -1) { in pointer_string()
703 spec.field_width = 2 * sizeof(ptr); in pointer_string()
704 spec.flags |= ZEROPAD; in pointer_string()
707 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
795 struct printf_spec spec) in ptr_to_id() argument
806 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
811 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
816 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
818 return error_string(buf, end, str, spec); in ptr_to_id()
821 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
828 struct printf_spec spec) in restricted_pointer() argument
833 return ptr_to_id(buf, end, ptr, spec); in restricted_pointer()
842 if (spec.field_width == -1) in restricted_pointer()
843 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
844 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
870 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
874 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
892 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
907 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
919 return widen_string(buf, n, end, spec); in dentry_name()
924 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
926 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
929 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
934 struct printf_spec spec, const char *fmt) in bdev_name() argument
938 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
942 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
949 buf = number(buf, end, bdev->bd_partno, spec); in bdev_name()
957 struct printf_spec spec, const char *fmt) in symbol_string() argument
976 return string_nocheck(buf, end, sym, spec); in symbol_string()
1014 struct printf_spec spec, const char *fmt) in resource_string() argument
1060 if (check_pointer(&buf, end, res, spec)) in resource_string()
1110 return string_nocheck(buf, end, sym, spec); in resource_string()
1114 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1121 if (spec.field_width == 0) in hex_string()
1125 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1143 if (spec.field_width > 0) in hex_string()
1144 len = min_t(int, spec.field_width, 64); in hex_string()
1166 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1169 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1173 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1177 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1200 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1201 buf = number(buf, end, val, spec); in bitmap_string()
1210 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1212 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1217 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1250 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1258 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1286 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1440 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1449 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1454 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1460 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1465 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1509 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1514 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1518 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1522 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1527 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1553 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1557 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1562 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1566 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1571 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1573 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1583 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1585 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1587 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1592 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1596 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1604 if (spec.field_width == 0) in escaped_string()
1607 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1642 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1655 struct printf_spec spec, const char *fmt) in va_format() argument
1659 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1671 struct printf_spec spec, const char *fmt) in uuid_string() argument
1679 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1711 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1716 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1721 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1730 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1738 struct printf_spec spec, const char *fmt) in address_val() argument
1743 if (check_pointer(&buf, end, addr, spec)) in address_val()
1798 struct printf_spec spec, const char *fmt) in rtc_str() argument
1804 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1836 struct printf_spec spec, const char *fmt) in time64_str() argument
1854 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1858 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1863 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1865 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1867 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1872 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1876 return error_string(buf, end, "(%pC?)", spec); in clock()
1878 if (check_pointer(&buf, end, clk, spec)) in clock()
1885 return string(buf, end, __clk_get_name(clk), spec); in clock()
1887 return ptr_to_id(buf, end, clk, spec); in clock()
1921 struct printf_spec spec, const char *fmt) in flags_string() argument
1926 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
1945 return error_string(buf, end, "(%pG?)", spec); in flags_string()
1975 struct printf_spec spec, const char *fmt) in device_node_string() argument
1984 struct printf_spec str_spec = spec; in device_node_string()
1988 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
1991 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
1993 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2024 case 'P': /* path-spec */ in device_node_string()
2060 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2065 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2067 struct printf_spec str_spec = spec; in fwnode_string()
2073 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2075 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2090 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2194 * P device node path spec (name + @unit)
2216 struct printf_spec spec) in pointer() argument
2224 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2227 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2229 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2233 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2235 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2241 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2251 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2253 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2255 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2257 return va_format(buf, end, ptr, spec, fmt); in pointer()
2259 return restricted_pointer(buf, end, ptr, spec); in pointer()
2261 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2263 return address_val(buf, end, ptr, spec, fmt); in pointer()
2265 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2267 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2269 return clock(buf, end, ptr, spec, fmt); in pointer()
2271 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2274 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2278 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2280 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2282 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2284 return pointer_string(buf, end, ptr, spec); in pointer()
2289 return err_ptr(buf, end, ptr, spec); in pointer()
2294 return string(buf, end, ptr, spec); in pointer()
2296 return error_string(buf, end, "(einval)", spec); in pointer()
2301 return ptr_to_id(buf, end, ptr, spec); in pointer()
2326 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2332 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2333 if (spec->field_width < 0) { in format_decode()
2334 spec->field_width = -spec->field_width; in format_decode()
2335 spec->flags |= LEFT; in format_decode()
2337 spec->type = FORMAT_TYPE_NONE; in format_decode()
2342 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2343 if (spec->precision < 0) in format_decode()
2344 spec->precision = 0; in format_decode()
2346 spec->type = FORMAT_TYPE_NONE; in format_decode()
2351 spec->type = FORMAT_TYPE_NONE; in format_decode()
2363 spec->flags = 0; in format_decode()
2371 case '-': spec->flags |= LEFT; break; in format_decode()
2372 case '+': spec->flags |= PLUS; break; in format_decode()
2373 case ' ': spec->flags |= SPACE; break; in format_decode()
2374 case '#': spec->flags |= SPECIAL; break; in format_decode()
2375 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2384 spec->field_width = -1; in format_decode()
2387 spec->field_width = skip_atoi(&fmt); in format_decode()
2390 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2396 spec->precision = -1; in format_decode()
2400 spec->precision = skip_atoi(&fmt); in format_decode()
2401 if (spec->precision < 0) in format_decode()
2402 spec->precision = 0; in format_decode()
2405 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2428 spec->base = 10; in format_decode()
2431 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2435 spec->type = FORMAT_TYPE_STR; in format_decode()
2439 spec->type = FORMAT_TYPE_PTR; in format_decode()
2443 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2448 spec->base = 8; in format_decode()
2452 spec->flags |= SMALL; in format_decode()
2456 spec->base = 16; in format_decode()
2461 spec->flags |= SIGN; in format_decode()
2475 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2480 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2483 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2485 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2487 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2490 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2493 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2496 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2503 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2505 spec->field_width = width; in set_field_width()
2506 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2507 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2512 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2514 spec->precision = prec; in set_precision()
2515 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2516 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2552 struct printf_spec spec = {0}; in vsnprintf() local
2570 int read = format_decode(fmt, &spec); in vsnprintf()
2574 switch (spec.type) { in vsnprintf()
2587 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2591 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2597 if (!(spec.flags & LEFT)) { in vsnprintf()
2598 while (--spec.field_width > 0) { in vsnprintf()
2609 while (--spec.field_width > 0) { in vsnprintf()
2618 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2623 spec); in vsnprintf()
2646 switch (spec.type) { in vsnprintf()
2657 if (spec.flags & SIGN) in vsnprintf()
2684 str = number(str, end, num, spec); in vsnprintf()
2853 struct printf_spec spec = {0}; in vbin_printf() local
2885 int read = format_decode(fmt, &spec); in vbin_printf()
2889 switch (spec.type) { in vbin_printf()
2901 set_field_width(&spec, width); in vbin_printf()
2941 spec); in vbin_printf()
2953 switch (spec.type) { in vbin_printf()
3012 struct printf_spec spec = {0}; in bstr_printf() local
3045 int read = format_decode(fmt, &spec); in bstr_printf()
3049 switch (spec.type) { in bstr_printf()
3062 set_field_width(&spec, get_arg(int)); in bstr_printf()
3066 set_precision(&spec, get_arg(int)); in bstr_printf()
3072 if (!(spec.flags & LEFT)) { in bstr_printf()
3073 while (--spec.field_width > 0) { in bstr_printf()
3083 while (--spec.field_width > 0) { in bstr_printf()
3094 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3128 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3147 switch (spec.type) { in bstr_printf()
3181 str = number(str, end, num, spec); in bstr_printf()
3183 } /* switch(spec.type) */ in bstr_printf()