• Home
  • Raw
  • Download

Lines Matching full:spec

449 	     struct printf_spec spec)  in number()  argument
455 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); in number()
458 int field_width = spec.field_width; in number()
459 int precision = spec.precision; in number()
463 locase = (spec.flags & SMALL); in number()
464 if (spec.flags & LEFT) in number()
465 spec.flags &= ~ZEROPAD; in number()
467 if (spec.flags & SIGN) { in number()
472 } else if (spec.flags & PLUS) { in number()
475 } else if (spec.flags & SPACE) { in number()
481 if (spec.base == 16) in number()
489 if (num < spec.base) in number()
491 else if (spec.base != 10) { /* 8 or 16 */ in number()
492 int mask = spec.base - 1; in number()
495 if (spec.base == 16) in number()
510 if (!(spec.flags & (ZEROPAD | LEFT))) { in number()
525 if (spec.base == 16 || !is_zero) { in number()
530 if (spec.base == 16) { in number()
537 if (!(spec.flags & LEFT)) { in number()
538 char c = ' ' + (spec.flags & ZEROPAD); in number()
571 struct printf_spec spec; in special_hex_number() local
573 spec.type = FORMAT_TYPE_PTR; in special_hex_number()
574 spec.field_width = 2 + 2 * size; /* 0x + hex */ in special_hex_number()
575 spec.flags = SPECIAL | SMALL | ZEROPAD; in special_hex_number()
576 spec.base = 16; in special_hex_number()
577 spec.precision = -1; in special_hex_number()
579 return number(buf, end, num, spec); in special_hex_number()
605 * @spec: for field width and flags
609 char *widen_string(char *buf, int n, char *end, struct printf_spec spec) in widen_string() argument
613 if (likely(n >= spec.field_width)) in widen_string()
616 spaces = spec.field_width - n; in widen_string()
617 if (!(spec.flags & LEFT)) { in widen_string()
631 struct printf_spec spec) in string_nocheck() argument
634 int lim = spec.precision; in string_nocheck()
645 return widen_string(buf, len, end, spec); in string_nocheck()
649 struct printf_spec spec) in err_ptr() argument
655 return string_nocheck(buf, end, sym, spec); in err_ptr()
662 spec.flags |= SIGN; in err_ptr()
663 spec.base = 10; in err_ptr()
664 return number(buf, end, err, spec); in err_ptr()
669 struct printf_spec spec) in error_string() argument
676 if (spec.precision == -1) in error_string()
677 spec.precision = 2 * sizeof(void *); in error_string()
679 return string_nocheck(buf, end, s, spec); in error_string()
699 struct printf_spec spec) in check_pointer() argument
705 *buf = error_string(*buf, end, err_msg, spec); in check_pointer()
714 struct printf_spec spec) in string() argument
716 if (check_pointer(&buf, end, s, spec)) in string()
719 return string_nocheck(buf, end, s, spec); in string()
724 struct printf_spec spec) in pointer_string() argument
726 spec.base = 16; in pointer_string()
727 spec.flags |= SMALL; in pointer_string()
728 if (spec.field_width == -1) { in pointer_string()
729 spec.field_width = 2 * sizeof(ptr); in pointer_string()
730 spec.flags |= ZEROPAD; in pointer_string()
733 return number(buf, end, (unsigned long int)ptr, spec); in pointer_string()
821 struct printf_spec spec) in ptr_to_id() argument
832 return pointer_string(buf, end, ptr, spec); in ptr_to_id()
837 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
842 spec.field_width = 2 * sizeof(ptr); in ptr_to_id()
844 return error_string(buf, end, str, spec); in ptr_to_id()
847 return pointer_string(buf, end, (const void *)hashval, spec); in ptr_to_id()
854 struct printf_spec spec) in restricted_pointer() argument
859 return ptr_to_id(buf, end, ptr, spec); in restricted_pointer()
868 if (spec.field_width == -1) in restricted_pointer()
869 spec.field_width = 2 * sizeof(ptr); in restricted_pointer()
870 return error_string(buf, end, "pK-error", spec); in restricted_pointer()
896 return pointer_string(buf, end, ptr, spec); in restricted_pointer()
900 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec, in dentry_name() argument
918 if (check_pointer(&buf, end, d, spec)) { in dentry_name()
933 for (n = 0; n != spec.precision; n++, buf++) { in dentry_name()
945 return widen_string(buf, n, end, spec); in dentry_name()
950 struct printf_spec spec, const char *fmt) in file_dentry_name() argument
952 if (check_pointer(&buf, end, f, spec)) in file_dentry_name()
955 return dentry_name(buf, end, f->f_path.dentry, spec, fmt); in file_dentry_name()
960 struct printf_spec spec, const char *fmt) in bdev_name() argument
964 if (check_pointer(&buf, end, bdev, spec)) in bdev_name()
968 buf = string(buf, end, hd->disk_name, spec); in bdev_name()
975 buf = number(buf, end, bdev->bd_partno, spec); in bdev_name()
983 struct printf_spec spec, const char *fmt) in symbol_string() argument
1002 return string_nocheck(buf, end, sym, spec); in symbol_string()
1040 struct printf_spec spec, const char *fmt) in resource_string() argument
1086 if (check_pointer(&buf, end, res, spec)) in resource_string()
1136 return string_nocheck(buf, end, sym, spec); in resource_string()
1140 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in hex_string() argument
1147 if (spec.field_width == 0) in hex_string()
1151 if (check_pointer(&buf, end, addr, spec)) in hex_string()
1169 if (spec.field_width > 0) in hex_string()
1170 len = min_t(int, spec.field_width, 64); in hex_string()
1192 struct printf_spec spec, const char *fmt) in bitmap_string() argument
1195 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_string()
1199 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_string()
1203 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 }; in bitmap_string()
1226 spec.field_width = DIV_ROUND_UP(chunksz, 4); in bitmap_string()
1227 buf = number(buf, end, val, spec); in bitmap_string()
1236 struct printf_spec spec, const char *fmt) in bitmap_list_string() argument
1238 int nr_bits = max_t(int, spec.field_width, 0); in bitmap_list_string()
1243 if (check_pointer(&buf, end, bitmap, spec)) in bitmap_list_string()
1276 struct printf_spec spec, const char *fmt) in mac_address_string() argument
1284 if (check_pointer(&buf, end, addr, spec)) in mac_address_string()
1312 return string_nocheck(buf, end, mac_addr, spec); in mac_address_string()
1466 struct printf_spec spec, const char *fmt) in ip6_addr_string() argument
1475 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string()
1480 struct printf_spec spec, const char *fmt) in ip4_addr_string() argument
1486 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string()
1491 struct printf_spec spec, const char *fmt) in ip6_addr_string_sa() argument
1535 p = number(p, pend, ntohs(sa->sin6_port), spec); in ip6_addr_string_sa()
1540 IPV6_FLOWINFO_MASK), spec); in ip6_addr_string_sa()
1544 p = number(p, pend, sa->sin6_scope_id, spec); in ip6_addr_string_sa()
1548 return string_nocheck(buf, end, ip6_addr, spec); in ip6_addr_string_sa()
1553 struct printf_spec spec, const char *fmt) in ip4_addr_string_sa() argument
1579 p = number(p, pend, ntohs(sa->sin_port), spec); in ip4_addr_string_sa()
1583 return string_nocheck(buf, end, ip4_addr, spec); in ip4_addr_string_sa()
1588 struct printf_spec spec, const char *fmt) in ip_addr_string() argument
1592 if (check_pointer(&buf, end, ptr, spec)) in ip_addr_string()
1597 return ip6_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1599 return ip4_addr_string(buf, end, ptr, spec, fmt); in ip_addr_string()
1609 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt); in ip_addr_string()
1611 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt); in ip_addr_string()
1613 return error_string(buf, end, "(einval)", spec); in ip_addr_string()
1618 return error_string(buf, end, err_fmt_msg, spec); in ip_addr_string()
1622 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec, in escaped_string() argument
1630 if (spec.field_width == 0) in escaped_string()
1633 if (check_pointer(&buf, end, addr, spec)) in escaped_string()
1668 len = spec.field_width < 0 ? 1 : spec.field_width; in escaped_string()
1681 struct printf_spec spec, const char *fmt) in va_format() argument
1685 if (check_pointer(&buf, end, va_fmt, spec)) in va_format()
1697 struct printf_spec spec, const char *fmt) in uuid_string() argument
1705 if (check_pointer(&buf, end, addr, spec)) in uuid_string()
1737 return string_nocheck(buf, end, uuid, spec); in uuid_string()
1742 struct printf_spec spec, const char *fmt) in netdev_bits() argument
1747 if (check_pointer(&buf, end, addr, spec)) in netdev_bits()
1756 return error_string(buf, end, "(%pN?)", spec); in netdev_bits()
1764 struct printf_spec spec, const char *fmt) in address_val() argument
1769 if (check_pointer(&buf, end, addr, spec)) in address_val()
1824 struct printf_spec spec, const char *fmt) in rtc_str() argument
1830 if (check_pointer(&buf, end, tm, spec)) in rtc_str()
1862 struct printf_spec spec, const char *fmt) in time64_str() argument
1880 return rtc_str(buf, end, &rtc_time, spec, fmt); in time64_str()
1884 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, in time_and_date() argument
1889 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt); in time_and_date()
1891 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt); in time_and_date()
1893 return error_string(buf, end, "(%pt?)", spec); in time_and_date()
1898 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, in clock() argument
1902 return error_string(buf, end, "(%pC?)", spec); in clock()
1904 if (check_pointer(&buf, end, clk, spec)) in clock()
1911 return string(buf, end, __clk_get_name(clk), spec); in clock()
1913 return ptr_to_id(buf, end, clk, spec); in clock()
1947 struct printf_spec spec, const char *fmt) in flags_string() argument
1952 if (check_pointer(&buf, end, flags_ptr, spec)) in flags_string()
1971 return error_string(buf, end, "(%pG?)", spec); in flags_string()
2001 struct printf_spec spec, const char *fmt) in device_node_string() argument
2010 struct printf_spec str_spec = spec; in device_node_string()
2014 return error_string(buf, end, "(%pO?)", spec); in device_node_string()
2017 return error_string(buf, end, "(%pOF?)", spec); in device_node_string()
2019 if (check_pointer(&buf, end, dn, spec)) in device_node_string()
2050 case 'P': /* path-spec */ in device_node_string()
2086 return widen_string(buf, buf - buf_start, end, spec); in device_node_string()
2091 struct printf_spec spec, const char *fmt) in fwnode_string() argument
2093 struct printf_spec str_spec = spec; in fwnode_string()
2099 return error_string(buf, end, "(%pf?)", spec); in fwnode_string()
2101 if (check_pointer(&buf, end, fwnode, spec)) in fwnode_string()
2116 return widen_string(buf, buf - buf_start, end, spec); in fwnode_string()
2220 * P device node path spec (name + @unit)
2242 struct printf_spec spec) in pointer() argument
2250 return symbol_string(buf, end, ptr, spec, fmt); in pointer()
2253 return resource_string(buf, end, ptr, spec, fmt); in pointer()
2255 return hex_string(buf, end, ptr, spec, fmt); in pointer()
2259 return bitmap_list_string(buf, end, ptr, spec, fmt); in pointer()
2261 return bitmap_string(buf, end, ptr, spec, fmt); in pointer()
2267 return mac_address_string(buf, end, ptr, spec, fmt); in pointer()
2277 return ip_addr_string(buf, end, ptr, spec, fmt); in pointer()
2279 return escaped_string(buf, end, ptr, spec, fmt); in pointer()
2281 return uuid_string(buf, end, ptr, spec, fmt); in pointer()
2283 return va_format(buf, end, ptr, spec, fmt); in pointer()
2285 return restricted_pointer(buf, end, ptr, spec); in pointer()
2287 return netdev_bits(buf, end, ptr, spec, fmt); in pointer()
2289 return address_val(buf, end, ptr, spec, fmt); in pointer()
2291 return dentry_name(buf, end, ptr, spec, fmt); in pointer()
2293 return time_and_date(buf, end, ptr, spec, fmt); in pointer()
2295 return clock(buf, end, ptr, spec, fmt); in pointer()
2297 return file_dentry_name(buf, end, ptr, spec, fmt); in pointer()
2300 return bdev_name(buf, end, ptr, spec, fmt); in pointer()
2304 return flags_string(buf, end, ptr, spec, fmt); in pointer()
2306 return device_node_string(buf, end, ptr, spec, fmt + 1); in pointer()
2308 return fwnode_string(buf, end, ptr, spec, fmt + 1); in pointer()
2310 return pointer_string(buf, end, ptr, spec); in pointer()
2315 return err_ptr(buf, end, ptr, spec); in pointer()
2320 return string(buf, end, ptr, spec); in pointer()
2322 return error_string(buf, end, "(einval)", spec); in pointer()
2327 return ptr_to_id(buf, end, ptr, spec); in pointer()
2352 int format_decode(const char *fmt, struct printf_spec *spec) in format_decode() argument
2358 if (spec->type == FORMAT_TYPE_WIDTH) { in format_decode()
2359 if (spec->field_width < 0) { in format_decode()
2360 spec->field_width = -spec->field_width; in format_decode()
2361 spec->flags |= LEFT; in format_decode()
2363 spec->type = FORMAT_TYPE_NONE; in format_decode()
2368 if (spec->type == FORMAT_TYPE_PRECISION) { in format_decode()
2369 if (spec->precision < 0) in format_decode()
2370 spec->precision = 0; in format_decode()
2372 spec->type = FORMAT_TYPE_NONE; in format_decode()
2377 spec->type = FORMAT_TYPE_NONE; in format_decode()
2389 spec->flags = 0; in format_decode()
2397 case '-': spec->flags |= LEFT; break; in format_decode()
2398 case '+': spec->flags |= PLUS; break; in format_decode()
2399 case ' ': spec->flags |= SPACE; break; in format_decode()
2400 case '#': spec->flags |= SPECIAL; break; in format_decode()
2401 case '0': spec->flags |= ZEROPAD; break; in format_decode()
2410 spec->field_width = -1; in format_decode()
2413 spec->field_width = skip_atoi(&fmt); in format_decode()
2416 spec->type = FORMAT_TYPE_WIDTH; in format_decode()
2422 spec->precision = -1; in format_decode()
2426 spec->precision = skip_atoi(&fmt); in format_decode()
2427 if (spec->precision < 0) in format_decode()
2428 spec->precision = 0; in format_decode()
2431 spec->type = FORMAT_TYPE_PRECISION; in format_decode()
2454 spec->base = 10; in format_decode()
2457 spec->type = FORMAT_TYPE_CHAR; in format_decode()
2461 spec->type = FORMAT_TYPE_STR; in format_decode()
2465 spec->type = FORMAT_TYPE_PTR; in format_decode()
2469 spec->type = FORMAT_TYPE_PERCENT_CHAR; in format_decode()
2474 spec->base = 8; in format_decode()
2478 spec->flags |= SMALL; in format_decode()
2482 spec->base = 16; in format_decode()
2487 spec->flags |= SIGN; in format_decode()
2501 spec->type = FORMAT_TYPE_INVALID; in format_decode()
2506 spec->type = FORMAT_TYPE_LONG_LONG; in format_decode()
2509 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN); in format_decode()
2511 spec->type = FORMAT_TYPE_SIZE_T; in format_decode()
2513 spec->type = FORMAT_TYPE_PTRDIFF; in format_decode()
2516 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN); in format_decode()
2519 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN); in format_decode()
2522 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN); in format_decode()
2529 set_field_width(struct printf_spec *spec, int width) in set_field_width() argument
2531 spec->field_width = width; in set_field_width()
2532 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) { in set_field_width()
2533 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); in set_field_width()
2538 set_precision(struct printf_spec *spec, int prec) in set_precision() argument
2540 spec->precision = prec; in set_precision()
2541 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) { in set_precision()
2542 spec->precision = clamp(prec, 0, PRECISION_MAX); in set_precision()
2578 struct printf_spec spec = {0}; in vsnprintf() local
2596 int read = format_decode(fmt, &spec); in vsnprintf()
2600 switch (spec.type) { in vsnprintf()
2613 set_field_width(&spec, va_arg(args, int)); in vsnprintf()
2617 set_precision(&spec, va_arg(args, int)); in vsnprintf()
2623 if (!(spec.flags & LEFT)) { in vsnprintf()
2624 while (--spec.field_width > 0) { in vsnprintf()
2635 while (--spec.field_width > 0) { in vsnprintf()
2644 str = string(str, end, va_arg(args, char *), spec); in vsnprintf()
2649 spec); in vsnprintf()
2672 switch (spec.type) { in vsnprintf()
2683 if (spec.flags & SIGN) in vsnprintf()
2710 str = number(str, end, num, spec); in vsnprintf()
2879 struct printf_spec spec = {0}; in vbin_printf() local
2911 int read = format_decode(fmt, &spec); in vbin_printf()
2915 switch (spec.type) { in vbin_printf()
2927 set_field_width(&spec, width); in vbin_printf()
2967 spec); in vbin_printf()
2979 switch (spec.type) { in vbin_printf()
3038 struct printf_spec spec = {0}; in bstr_printf() local
3071 int read = format_decode(fmt, &spec); in bstr_printf()
3075 switch (spec.type) { in bstr_printf()
3088 set_field_width(&spec, get_arg(int)); in bstr_printf()
3092 set_precision(&spec, get_arg(int)); in bstr_printf()
3098 if (!(spec.flags & LEFT)) { in bstr_printf()
3099 while (--spec.field_width > 0) { in bstr_printf()
3109 while (--spec.field_width > 0) { in bstr_printf()
3120 str = string(str, end, (char *)str_arg, spec); in bstr_printf()
3152 str = pointer(fmt, str, end, get_arg(void *), spec); in bstr_printf()
3171 switch (spec.type) { in bstr_printf()
3205 str = number(str, end, num, spec); in bstr_printf()
3207 } /* switch(spec.type) */ in bstr_printf()