Lines Matching full:spec

453 	     struct printf_spec spec)  in number()  argument
459 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
462 int field_width = spec.field_width; in number()
463 int precision = spec.precision; in number()
467 locase = (spec.flags & SMALL); in number()
468 if (spec.flags & LEFT) in number()
469 spec.flags &= ~ZEROPAD; in number()
471 if (spec.flags & SIGN) { in number()
476 } else if (spec.flags & PLUS) { in number()
479 } else if (spec.flags & SPACE) { in number()
485 if (spec.base == 16) in number()
493 if (num < spec.base) in number()
495 else if (spec.base != 10) { /* 8 or 16 */ in number()
496 int mask = spec.base - 1; in number()
499 if (spec.base == 16) in number()
514 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
529 if (spec.base == 16 || !is_zero) { in number()
534 if (spec.base == 16) { in number()
541 if (!(spec.flags & LEFT)) { in number()
542 char c = ' ' + (spec.flags & ZEROPAD); in number()
575 struct printf_spec spec; in special_hex_number() local
577 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
578 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
579 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
580 spec.base = 16; in special_hex_number()
581 spec.precision = -1; in special_hex_number()
583 return number(buf, end, num, spec); in special_hex_number()
609 * @spec: for field width and flags
613 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
617 if (likely(n >= spec.field_width)) in widen_string()
620 spaces = spec.field_width - n; in widen_string()
621 if (!(spec.flags & LEFT)) { in widen_string()
635 struct printf_spec spec) in string_nocheck() argument
638 int lim = spec.precision; in string_nocheck()
649 return widen_string(buf, len, end, spec); in string_nocheck()
653 struct printf_spec spec) in err_ptr() argument
659 return string_nocheck(buf, end, sym, spec); in err_ptr()
666 spec.flags |= SIGN; in err_ptr()
667 spec.base = 10; in err_ptr()
668 return number(buf, end, err, spec); in err_ptr()
673 struct printf_spec spec) in error_string() argument
680 if (spec.precision == -1) in error_string()
681 spec.precision = 2 * sizeof(void *); in error_string()
683 return string_nocheck(buf, end, s, spec); in error_string()
703 struct printf_spec spec) in check_pointer() argument
709 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
718 struct printf_spec spec) in string() argument
720 if (check_pointer(&buf, end, s, spec)) in string()
723 return string_nocheck(buf, end, s, spec); in string()
728 struct printf_spec spec) in pointer_string() argument
730 spec.base = 16; in pointer_string()
731 spec.flags |= SMALL; in pointer_string()
732 if (spec.field_width == -1) { in pointer_string()
733 spec.field_width = 2 * sizeof(ptr); in pointer_string()
734 spec.flags |= ZEROPAD; in pointer_string()
737 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
827 struct printf_spec spec) in ptr_to_id() argument
838 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
843 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
848 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
850 return error_string(buf, end, str, spec); in ptr_to_id()
853 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
857 struct printf_spec spec) in default_pointer() argument
864 return pointer_string(buf, end, ptr, spec); in default_pointer()
866 return ptr_to_id(buf, end, ptr, spec); in default_pointer()
873 struct printf_spec spec) in restricted_pointer() argument
878 return default_pointer(buf, end, ptr, spec); in restricted_pointer()
887 if (spec.field_width == -1) in restricted_pointer()
888 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
889 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
915 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
919 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
937 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
952 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
964 return widen_string(buf, n, end, spec); in dentry_name()
969 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
971 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
974 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
979 struct printf_spec spec, const char *fmt) in bdev_name() argument
983 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
987 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
994 buf = number(buf, end, bdev->bd_partno, spec); in bdev_name()
1002 struct printf_spec spec, const char *fmt) in symbol_string() argument
1021 return string_nocheck(buf, end, sym, spec); in symbol_string()
1059 struct printf_spec spec, const char *fmt) in resource_string() argument
1105 if (check_pointer(&buf, end, res, spec)) in resource_string()
1155 return string_nocheck(buf, end, sym, spec); in resource_string()
1159 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1166 if (spec.field_width == 0) in hex_string()
1170 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1188 if (spec.field_width > 0) in hex_string()
1189 len = min_t(int, spec.field_width, 64); in hex_string()
1211 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1214 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1218 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1222 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1245 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1246 buf = number(buf, end, val, spec); in bitmap_string()
1255 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1257 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1262 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1295 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1303 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1331 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1485 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1494 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1499 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1505 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1510 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1554 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1559 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1563 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1567 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1572 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1598 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1602 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1607 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1611 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1616 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1618 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1628 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1630 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1632 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1637 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1641 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1649 if (spec.field_width == 0) in escaped_string()
1652 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1687 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1700 struct printf_spec spec, const char *fmt) in va_format() argument
1704 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1716 struct printf_spec spec, const char *fmt) in uuid_string() argument
1724 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1756 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1761 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1766 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1775 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1783 struct printf_spec spec, const char *fmt) in address_val() argument
1788 if (check_pointer(&buf, end, addr, spec)) in address_val()
1843 struct printf_spec spec, const char *fmt) in rtc_str() argument
1849 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1881 struct printf_spec spec, const char *fmt) in time64_str() argument
1899 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1903 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1908 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1910 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1912 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1917 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1921 return error_string(buf, end, "(%pC?)", spec); in clock()
1923 if (check_pointer(&buf, end, clk, spec)) in clock()
1930 return string(buf, end, __clk_get_name(clk), spec); in clock()
1932 return ptr_to_id(buf, end, clk, spec); in clock()
1966 struct printf_spec spec, const char *fmt) in flags_string() argument
1971 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
1990 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2020 struct printf_spec spec, const char *fmt) in device_node_string() argument
2029 struct printf_spec str_spec = spec; in device_node_string()
2033 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2036 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2038 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2069 case 'P': /* path-spec */ in device_node_string()
2105 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2110 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2112 struct printf_spec str_spec = spec; in fwnode_string()
2118 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2120 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2135 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2261 * P device node path spec (name + @unit)
2283 struct printf_spec spec) in pointer() argument
2291 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2294 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2296 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2300 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2302 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2308 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2318 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2320 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2322 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2324 return va_format(buf, end, ptr, spec, fmt); in pointer()
2326 return restricted_pointer(buf, end, ptr, spec); in pointer()
2328 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2330 return address_val(buf, end, ptr, spec, fmt); in pointer()
2332 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2334 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2336 return clock(buf, end, ptr, spec, fmt); in pointer()
2338 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2341 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2345 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2347 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2349 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2351 return pointer_string(buf, end, ptr, spec); in pointer()
2355 return default_pointer(buf, end, ptr, spec); in pointer()
2356 return err_ptr(buf, end, ptr, spec); in pointer()
2361 return string(buf, end, ptr, spec); in pointer()
2363 return error_string(buf, end, "(einval)", spec); in pointer()
2366 return default_pointer(buf, end, ptr, spec); in pointer()
2392 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2398 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2399 if (spec->field_width < 0) { in format_decode()
2400 spec->field_width = -spec->field_width; in format_decode()
2401 spec->flags |= LEFT; in format_decode()
2403 spec->type = FORMAT_TYPE_NONE; in format_decode()
2408 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2409 if (spec->precision < 0) in format_decode()
2410 spec->precision = 0; in format_decode()
2412 spec->type = FORMAT_TYPE_NONE; in format_decode()
2417 spec->type = FORMAT_TYPE_NONE; in format_decode()
2429 spec->flags = 0; in format_decode()
2437 case '-': spec->flags |= LEFT; break; in format_decode()
2438 case '+': spec->flags |= PLUS; break; in format_decode()
2439 case ' ': spec->flags |= SPACE; break; in format_decode()
2440 case '#': spec->flags |= SPECIAL; break; in format_decode()
2441 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2450 spec->field_width = -1; in format_decode()
2453 spec->field_width = skip_atoi(&fmt); in format_decode()
2456 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2462 spec->precision = -1; in format_decode()
2466 spec->precision = skip_atoi(&fmt); in format_decode()
2467 if (spec->precision < 0) in format_decode()
2468 spec->precision = 0; in format_decode()
2471 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2494 spec->base = 10; in format_decode()
2497 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2501 spec->type = FORMAT_TYPE_STR; in format_decode()
2505 spec->type = FORMAT_TYPE_PTR; in format_decode()
2509 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2514 spec->base = 8; in format_decode()
2518 spec->flags |= SMALL; in format_decode()
2522 spec->base = 16; in format_decode()
2527 spec->flags |= SIGN; in format_decode()
2541 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2546 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2549 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2551 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2553 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2556 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2559 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2562 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2569 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2571 spec->field_width = width; in set_field_width()
2572 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2573 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2578 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2580 spec->precision = prec; in set_precision()
2581 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2582 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2618 struct printf_spec spec = {0}; in vsnprintf() local
2636 int read = format_decode(fmt, &spec); in vsnprintf()
2640 switch (spec.type) { in vsnprintf()
2653 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2657 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2663 if (!(spec.flags & LEFT)) { in vsnprintf()
2664 while (--spec.field_width > 0) { in vsnprintf()
2675 while (--spec.field_width > 0) { in vsnprintf()
2684 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2689 spec); in vsnprintf()
2712 switch (spec.type) { in vsnprintf()
2723 if (spec.flags & SIGN) in vsnprintf()
2750 str = number(str, end, num, spec); in vsnprintf()
2919 struct printf_spec spec = {0}; in vbin_printf() local
2951 int read = format_decode(fmt, &spec); in vbin_printf()
2955 switch (spec.type) { in vbin_printf()
2967 set_field_width(&spec, width); in vbin_printf()
3007 spec); in vbin_printf()
3019 switch (spec.type) { in vbin_printf()
3078 struct printf_spec spec = {0}; in bstr_printf() local
3111 int read = format_decode(fmt, &spec); in bstr_printf()
3115 switch (spec.type) { in bstr_printf()
3128 set_field_width(&spec, get_arg(int)); in bstr_printf()
3132 set_precision(&spec, get_arg(int)); in bstr_printf()
3138 if (!(spec.flags & LEFT)) { in bstr_printf()
3139 while (--spec.field_width > 0) { in bstr_printf()
3149 while (--spec.field_width > 0) { in bstr_printf()
3160 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3192 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3211 switch (spec.type) { in bstr_printf()
3245 str = number(str, end, num, spec); in bstr_printf()
3247 } /* switch(spec.type) */ in bstr_printf()