Lines Matching refs:spec
417 struct printf_spec spec) in number() argument
423 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
426 int field_width = spec.field_width; in number()
427 int precision = spec.precision; in number()
431 locase = (spec.flags & SMALL); in number()
432 if (spec.flags & LEFT) in number()
433 spec.flags &= ~ZEROPAD; in number()
435 if (spec.flags & SIGN) { in number()
440 } else if (spec.flags & PLUS) { in number()
443 } else if (spec.flags & SPACE) { in number()
449 if (spec.base == 16) in number()
457 if (num < spec.base) in number()
459 else if (spec.base != 10) { /* 8 or 16 */ in number()
460 int mask = spec.base - 1; in number()
463 if (spec.base == 16) in number()
478 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
493 if (spec.base == 16 || !is_zero) { in number()
498 if (spec.base == 16) { in number()
505 if (!(spec.flags & LEFT)) { in number()
506 char c = ' ' + (spec.flags & ZEROPAD); in number()
539 struct printf_spec spec; in special_hex_number() local
541 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
542 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
543 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
544 spec.base = 16; in special_hex_number()
545 spec.precision = -1; in special_hex_number()
547 return number(buf, end, num, spec); in special_hex_number()
577 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
581 if (likely(n >= spec.field_width)) in widen_string()
584 spaces = spec.field_width - n; in widen_string()
585 if (!(spec.flags & LEFT)) { in widen_string()
599 struct printf_spec spec) in string_nocheck() argument
602 int lim = spec.precision; in string_nocheck()
613 return widen_string(buf, len, end, spec); in string_nocheck()
618 struct printf_spec spec) in error_string() argument
625 if (spec.precision == -1) in error_string()
626 spec.precision = 2 * sizeof(void *); in error_string()
628 return string_nocheck(buf, end, s, spec); in error_string()
648 struct printf_spec spec) in check_pointer() argument
654 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
663 struct printf_spec spec) in string() argument
665 if (check_pointer(&buf, end, s, spec)) in string()
668 return string_nocheck(buf, end, s, spec); in string()
673 struct printf_spec spec) in pointer_string() argument
675 spec.base = 16; in pointer_string()
676 spec.flags |= SMALL; in pointer_string()
677 if (spec.field_width == -1) { in pointer_string()
678 spec.field_width = 2 * sizeof(ptr); in pointer_string()
679 spec.flags |= ZEROPAD; in pointer_string()
682 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
744 struct printf_spec spec) in ptr_to_id() argument
752 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
756 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
758 return error_string(buf, end, str, spec); in ptr_to_id()
771 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
778 struct printf_spec spec) in restricted_pointer() argument
783 return ptr_to_id(buf, end, ptr, spec); in restricted_pointer()
792 if (spec.field_width == -1) in restricted_pointer()
793 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
794 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
820 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
824 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
842 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
857 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
869 return widen_string(buf, n, end, spec); in dentry_name()
874 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
876 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
879 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
884 struct printf_spec spec, const char *fmt) in bdev_name() argument
888 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
892 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
899 buf = number(buf, end, bdev->bd_part->partno, spec); in bdev_name()
907 struct printf_spec spec, const char *fmt) in symbol_string() argument
926 return string_nocheck(buf, end, sym, spec); in symbol_string()
964 struct printf_spec spec, const char *fmt) in resource_string() argument
1010 if (check_pointer(&buf, end, res, spec)) in resource_string()
1060 return string_nocheck(buf, end, sym, spec); in resource_string()
1064 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1071 if (spec.field_width == 0) in hex_string()
1075 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1093 if (spec.field_width > 0) in hex_string()
1094 len = min_t(int, spec.field_width, 64); in hex_string()
1116 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1119 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1123 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1127 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1150 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1151 buf = number(buf, end, val, spec); in bitmap_string()
1160 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1162 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1167 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1200 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1208 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1236 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1390 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1399 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1404 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1410 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1415 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1459 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1464 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1468 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1472 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1477 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1503 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1507 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1512 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1516 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1521 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1523 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1533 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1535 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1537 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1542 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1546 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1554 if (spec.field_width == 0) in escaped_string()
1557 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1592 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1605 struct printf_spec spec, const char *fmt) in va_format() argument
1609 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1621 struct printf_spec spec, const char *fmt) in uuid_string() argument
1629 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1660 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1665 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1670 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1679 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1687 struct printf_spec spec, const char *fmt) in address_val() argument
1692 if (check_pointer(&buf, end, addr, spec)) in address_val()
1747 struct printf_spec spec, const char *fmt) in rtc_str() argument
1753 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1784 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1789 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1791 return error_string(buf, end, "(%ptR?)", spec); in time_and_date()
1796 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1800 return error_string(buf, end, "(%pC?)", spec); in clock()
1802 if (check_pointer(&buf, end, clk, spec)) in clock()
1809 return string(buf, end, __clk_get_name(clk), spec); in clock()
1811 return ptr_to_id(buf, end, clk, spec); in clock()
1845 struct printf_spec spec, const char *fmt) in flags_string() argument
1850 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
1869 return error_string(buf, end, "(%pG?)", spec); in flags_string()
1906 struct printf_spec spec, const char *fmt) in device_node_string() argument
1921 struct printf_spec str_spec = spec; in device_node_string()
1925 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
1927 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
1993 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
1997 struct printf_spec spec, const char *fmt) in kobject_string() argument
2001 return device_node_string(buf, end, ptr, spec, fmt + 1); in kobject_string()
2004 return error_string(buf, end, "(%pO?)", spec); in kobject_string()
2121 struct printf_spec spec) in pointer() argument
2131 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2134 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2136 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2140 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2142 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2148 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2158 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2160 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2162 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2164 return va_format(buf, end, ptr, spec, fmt); in pointer()
2166 return restricted_pointer(buf, end, ptr, spec); in pointer()
2168 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2170 return address_val(buf, end, ptr, spec, fmt); in pointer()
2172 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2174 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2176 return clock(buf, end, ptr, spec, fmt); in pointer()
2178 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2181 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2185 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2187 return kobject_string(buf, end, ptr, spec, fmt); in pointer()
2189 return pointer_string(buf, end, ptr, spec); in pointer()
2193 return ptr_to_id(buf, end, ptr, spec); in pointer()
2218 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2224 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2225 if (spec->field_width < 0) { in format_decode()
2226 spec->field_width = -spec->field_width; in format_decode()
2227 spec->flags |= LEFT; in format_decode()
2229 spec->type = FORMAT_TYPE_NONE; in format_decode()
2234 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2235 if (spec->precision < 0) in format_decode()
2236 spec->precision = 0; in format_decode()
2238 spec->type = FORMAT_TYPE_NONE; in format_decode()
2243 spec->type = FORMAT_TYPE_NONE; in format_decode()
2255 spec->flags = 0; in format_decode()
2263 case '-': spec->flags |= LEFT; break; in format_decode()
2264 case '+': spec->flags |= PLUS; break; in format_decode()
2265 case ' ': spec->flags |= SPACE; break; in format_decode()
2266 case '#': spec->flags |= SPECIAL; break; in format_decode()
2267 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2276 spec->field_width = -1; in format_decode()
2279 spec->field_width = skip_atoi(&fmt); in format_decode()
2282 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2288 spec->precision = -1; in format_decode()
2292 spec->precision = skip_atoi(&fmt); in format_decode()
2293 if (spec->precision < 0) in format_decode()
2294 spec->precision = 0; in format_decode()
2297 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2320 spec->base = 10; in format_decode()
2323 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2327 spec->type = FORMAT_TYPE_STR; in format_decode()
2331 spec->type = FORMAT_TYPE_PTR; in format_decode()
2335 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2340 spec->base = 8; in format_decode()
2344 spec->flags |= SMALL; in format_decode()
2348 spec->base = 16; in format_decode()
2353 spec->flags |= SIGN; in format_decode()
2367 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2372 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2375 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2377 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2379 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2382 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2385 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2388 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2395 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2397 spec->field_width = width; in set_field_width()
2398 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2399 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2404 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2406 spec->precision = prec; in set_precision()
2407 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2408 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2444 struct printf_spec spec = {0}; in vsnprintf() local
2462 int read = format_decode(fmt, &spec); in vsnprintf()
2466 switch (spec.type) { in vsnprintf()
2479 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2483 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2489 if (!(spec.flags & LEFT)) { in vsnprintf()
2490 while (--spec.field_width > 0) { in vsnprintf()
2501 while (--spec.field_width > 0) { in vsnprintf()
2510 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2515 spec); in vsnprintf()
2538 switch (spec.type) { in vsnprintf()
2549 if (spec.flags & SIGN) in vsnprintf()
2576 str = number(str, end, num, spec); in vsnprintf()
2745 struct printf_spec spec = {0}; in vbin_printf() local
2777 int read = format_decode(fmt, &spec); in vbin_printf()
2781 switch (spec.type) { in vbin_printf()
2793 set_field_width(&spec, width); in vbin_printf()
2834 spec); in vbin_printf()
2846 switch (spec.type) { in vbin_printf()
2905 struct printf_spec spec = {0}; in bstr_printf() local
2938 int read = format_decode(fmt, &spec); in bstr_printf()
2942 switch (spec.type) { in bstr_printf()
2955 set_field_width(&spec, get_arg(int)); in bstr_printf()
2959 set_precision(&spec, get_arg(int)); in bstr_printf()
2965 if (!(spec.flags & LEFT)) { in bstr_printf()
2966 while (--spec.field_width > 0) { in bstr_printf()
2976 while (--spec.field_width > 0) { in bstr_printf()
2987 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3020 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3039 switch (spec.type) { in bstr_printf()
3073 str = number(str, end, num, spec); in bstr_printf()