Lines Matching defs:spec

457 	     struct printf_spec spec)
463 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
466 int field_width = spec.field_width;
467 int precision = spec.precision;
471 locase = (spec.flags & SMALL);
472 if (spec.flags & LEFT)
473 spec.flags &= ~ZEROPAD;
475 if (spec.flags & SIGN) {
480 } else if (spec.flags & PLUS) {
483 } else if (spec.flags & SPACE) {
489 if (spec.base == 16)
497 if (num < spec.base)
499 else if (spec.base != 10) { /* 8 or 16 */
500 int mask = spec.base - 1;
503 if (spec.base == 16)
518 if (!(spec.flags & (ZEROPAD | LEFT))) {
533 if (spec.base == 16 || !is_zero) {
538 if (spec.base == 16) {
545 if (!(spec.flags & LEFT)) {
546 char c = ' ' + (spec.flags & ZEROPAD);
579 struct printf_spec spec;
581 spec.type = FORMAT_TYPE_PTR;
582 spec.field_width = 2 + 2 * size; /* 0x + hex */
583 spec.flags = SPECIAL | SMALL | ZEROPAD;
584 spec.base = 16;
585 spec.precision = -1;
587 return number(buf, end, num, spec);
613 * @spec: for field width and flags
617 char *widen_string(char *buf, int n, char *end, struct printf_spec spec)
621 if (likely(n >= spec.field_width))
624 spaces = spec.field_width - n;
625 if (!(spec.flags & LEFT)) {
639 struct printf_spec spec)
642 int lim = spec.precision;
653 return widen_string(buf, len, end, spec);
657 struct printf_spec spec)
663 return string_nocheck(buf, end, sym, spec);
670 spec.flags |= SIGN;
671 spec.base = 10;
672 return number(buf, end, err, spec);
677 struct printf_spec spec)
684 if (spec.precision == -1)
685 spec.precision = 2 * sizeof(void *);
687 return string_nocheck(buf, end, s, spec);
707 struct printf_spec spec)
713 *buf = error_string(*buf, end, err_msg, spec);
722 struct printf_spec spec)
724 if (check_pointer(&buf, end, s, spec))
727 return string_nocheck(buf, end, s, spec);
732 struct printf_spec spec)
734 spec.base = 16;
735 spec.flags |= SMALL;
736 if (spec.field_width == -1) {
737 spec.field_width = 2 * sizeof(ptr);
738 spec.flags |= ZEROPAD;
741 return number(buf, end, (unsigned long int)ptr, spec);
807 struct printf_spec spec)
818 return pointer_string(buf, end, ptr, spec);
823 return pointer_string(buf, end, (const void *)hashval, spec);
828 spec.field_width = 2 * sizeof(ptr);
830 return error_string(buf, end, str, spec);
833 return pointer_string(buf, end, (const void *)hashval, spec);
837 struct printf_spec spec)
844 return pointer_string(buf, end, ptr, spec);
846 return ptr_to_id(buf, end, ptr, spec);
853 struct printf_spec spec)
858 return default_pointer(buf, end, ptr, spec);
867 if (spec.field_width == -1)
868 spec.field_width = 2 * sizeof(ptr);
869 return error_string(buf, end, "pK-error", spec);
895 return pointer_string(buf, end, ptr, spec);
899 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec,
917 if (check_pointer(&buf, end, d, spec)) {
932 for (n = 0; n != spec.precision; n++, buf++) {
944 return widen_string(buf, n, end, spec);
949 struct printf_spec spec, const char *fmt)
951 if (check_pointer(&buf, end, f, spec))
954 return dentry_name(buf, end, f->f_path.dentry, spec, fmt);
959 struct printf_spec spec, const char *fmt)
963 if (check_pointer(&buf, end, bdev, spec))
967 buf = string(buf, end, hd->disk_name, spec);
974 buf = number(buf, end, bdev->bd_partno, spec);
982 struct printf_spec spec, const char *fmt)
1005 return string_nocheck(buf, end, sym, spec);
1043 struct printf_spec spec, const char *fmt)
1089 if (check_pointer(&buf, end, res, spec))
1139 return string_nocheck(buf, end, sym, spec);
1143 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1150 if (spec.field_width == 0)
1154 if (check_pointer(&buf, end, addr, spec))
1172 if (spec.field_width > 0)
1173 len = min_t(int, spec.field_width, 64);
1195 struct printf_spec spec, const char *fmt)
1198 int nr_bits = max_t(int, spec.field_width, 0);
1202 if (check_pointer(&buf, end, bitmap, spec))
1206 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 };
1229 spec.field_width = DIV_ROUND_UP(chunksz, 4);
1230 buf = number(buf, end, val, spec);
1239 struct printf_spec spec, const char *fmt)
1241 int nr_bits = max_t(int, spec.field_width, 0);
1245 if (check_pointer(&buf, end, bitmap, spec))
1269 struct printf_spec spec, const char *fmt)
1277 if (check_pointer(&buf, end, addr, spec))
1305 return string_nocheck(buf, end, mac_addr, spec);
1459 struct printf_spec spec, const char *fmt)
1468 return string_nocheck(buf, end, ip6_addr, spec);
1473 struct printf_spec spec, const char *fmt)
1479 return string_nocheck(buf, end, ip4_addr, spec);
1484 struct printf_spec spec, const char *fmt)
1528 p = number(p, pend, ntohs(sa->sin6_port), spec);
1533 IPV6_FLOWINFO_MASK), spec);
1537 p = number(p, pend, sa->sin6_scope_id, spec);
1541 return string_nocheck(buf, end, ip6_addr, spec);
1546 struct printf_spec spec, const char *fmt)
1572 p = number(p, pend, ntohs(sa->sin_port), spec);
1576 return string_nocheck(buf, end, ip4_addr, spec);
1581 struct printf_spec spec, const char *fmt)
1585 if (check_pointer(&buf, end, ptr, spec))
1590 return ip6_addr_string(buf, end, ptr, spec, fmt);
1592 return ip4_addr_string(buf, end, ptr, spec, fmt);
1602 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt);
1604 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt);
1606 return error_string(buf, end, "(einval)", spec);
1611 return error_string(buf, end, err_fmt_msg, spec);
1615 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1623 if (spec.field_width == 0)
1626 if (check_pointer(&buf, end, addr, spec))
1661 len = spec.field_width < 0 ? 1 : spec.field_width;
1674 struct printf_spec spec, const char *fmt)
1678 if (check_pointer(&buf, end, va_fmt, spec))
1690 struct printf_spec spec, const char *fmt)
1698 if (check_pointer(&buf, end, addr, spec))
1730 return string_nocheck(buf, end, uuid, spec);
1735 struct printf_spec spec, const char *fmt)
1740 if (check_pointer(&buf, end, addr, spec))
1749 return error_string(buf, end, "(%pN?)", spec);
1757 struct printf_spec spec, const char *fmt)
1765 return error_string(buf, end, "(%p4?)", spec);
1767 if (check_pointer(&buf, end, fourcc, spec))
1790 return string(buf, end, output, spec);
1795 struct printf_spec spec, const char *fmt)
1800 if (check_pointer(&buf, end, addr, spec))
1855 struct printf_spec spec, const char *fmt)
1862 if (check_pointer(&buf, end, tm, spec))
1905 struct printf_spec spec, const char *fmt)
1923 return rtc_str(buf, end, &rtc_time, spec, fmt);
1927 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
1932 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
1934 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt);
1936 return error_string(buf, end, "(%pt?)", spec);
1941 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
1945 return error_string(buf, end, "(%pC?)", spec);
1947 if (check_pointer(&buf, end, clk, spec))
1954 return string(buf, end, __clk_get_name(clk), spec);
1956 return ptr_to_id(buf, end, clk, spec);
1992 const struct printf_spec *spec;
2045 *pff[i].spec);
2077 struct printf_spec spec, const char *fmt)
2082 if (check_pointer(&buf, end, flags_ptr, spec))
2099 return error_string(buf, end, "(%pG?)", spec);
2134 struct printf_spec spec, const char *fmt)
2143 struct printf_spec str_spec = spec;
2147 return error_string(buf, end, "(%pO?)", spec);
2150 return error_string(buf, end, "(%pOF?)", spec);
2152 if (check_pointer(&buf, end, dn, spec))
2183 case 'P': /* path-spec */
2219 return widen_string(buf, buf - buf_start, end, spec);
2224 struct printf_spec spec, const char *fmt)
2226 struct printf_spec str_spec = spec;
2232 return error_string(buf, end, "(%pf?)", spec);
2234 if (check_pointer(&buf, end, fwnode, spec))
2249 return widen_string(buf, buf - buf_start, end, spec);
2386 * P device node path spec (name + @unit)
2413 struct printf_spec spec)
2421 return symbol_string(buf, end, ptr, spec, fmt);
2424 return resource_string(buf, end, ptr, spec, fmt);
2426 return hex_string(buf, end, ptr, spec, fmt);
2430 return bitmap_list_string(buf, end, ptr, spec, fmt);
2432 return bitmap_string(buf, end, ptr, spec, fmt);
2438 return mac_address_string(buf, end, ptr, spec, fmt);
2448 return ip_addr_string(buf, end, ptr, spec, fmt);
2450 return escaped_string(buf, end, ptr, spec, fmt);
2452 return uuid_string(buf, end, ptr, spec, fmt);
2454 return va_format(buf, end, ptr, spec, fmt);
2456 return restricted_pointer(buf, end, ptr, spec);
2458 return netdev_bits(buf, end, ptr, spec, fmt);
2460 return fourcc_string(buf, end, ptr, spec, fmt);
2462 return address_val(buf, end, ptr, spec, fmt);
2464 return dentry_name(buf, end, ptr, spec, fmt);
2466 return time_and_date(buf, end, ptr, spec, fmt);
2468 return clock(buf, end, ptr, spec, fmt);
2470 return file_dentry_name(buf, end, ptr, spec, fmt);
2473 return bdev_name(buf, end, ptr, spec, fmt);
2477 return flags_string(buf, end, ptr, spec, fmt);
2479 return device_node_string(buf, end, ptr, spec, fmt + 1);
2481 return fwnode_string(buf, end, ptr, spec, fmt + 1);
2485 return error_string(buf, end, "(%pA?)", spec);
2489 return pointer_string(buf, end, ptr, spec);
2493 return default_pointer(buf, end, ptr, spec);
2494 return err_ptr(buf, end, ptr, spec);
2499 return string(buf, end, ptr, spec);
2501 return error_string(buf, end, "(einval)", spec);
2504 return default_pointer(buf, end, ptr, spec);
2530 int format_decode(const char *fmt, struct printf_spec *spec)
2536 if (spec->type == FORMAT_TYPE_WIDTH) {
2537 if (spec->field_width < 0) {
2538 spec->field_width = -spec->field_width;
2539 spec->flags |= LEFT;
2541 spec->type = FORMAT_TYPE_NONE;
2546 if (spec->type == FORMAT_TYPE_PRECISION) {
2547 if (spec->precision < 0)
2548 spec->precision = 0;
2550 spec->type = FORMAT_TYPE_NONE;
2555 spec->type = FORMAT_TYPE_NONE;
2567 spec->flags = 0;
2575 case '-': spec->flags |= LEFT; break;
2576 case '+': spec->flags |= PLUS; break;
2577 case ' ': spec->flags |= SPACE; break;
2578 case '#': spec->flags |= SPECIAL; break;
2579 case '0': spec->flags |= ZEROPAD; break;
2588 spec->field_width = -1;
2591 spec->field_width = skip_atoi(&fmt);
2594 spec->type = FORMAT_TYPE_WIDTH;
2600 spec->precision = -1;
2604 spec->precision = skip_atoi(&fmt);
2605 if (spec->precision < 0)
2606 spec->precision = 0;
2609 spec->type = FORMAT_TYPE_PRECISION;
2632 spec->base = 10;
2635 spec->type = FORMAT_TYPE_CHAR;
2639 spec->type = FORMAT_TYPE_STR;
2643 spec->type = FORMAT_TYPE_PTR;
2647 spec->type = FORMAT_TYPE_PERCENT_CHAR;
2652 spec->base = 8;
2656 spec->flags |= SMALL;
2660 spec->base = 16;
2665 spec->flags |= SIGN;
2680 spec->type = FORMAT_TYPE_INVALID;
2685 spec->type = FORMAT_TYPE_LONG_LONG;
2688 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN);
2690 spec->type = FORMAT_TYPE_SIZE_T;
2692 spec->type = FORMAT_TYPE_PTRDIFF;
2695 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN);
2698 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN);
2701 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN);
2708 set_field_width(struct printf_spec *spec, int width)
2710 spec->field_width = width;
2711 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) {
2712 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX);
2717 set_precision(struct printf_spec *spec, int prec)
2719 spec->precision = prec;
2720 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) {
2721 spec->precision = clamp(prec, 0, PRECISION_MAX);
2757 struct printf_spec spec = {0};
2775 int read = format_decode(fmt, &spec);
2779 switch (spec.type) {
2792 set_field_width(&spec, va_arg(args, int));
2796 set_precision(&spec, va_arg(args, int));
2802 if (!(spec.flags & LEFT)) {
2803 while (--spec.field_width > 0) {
2814 while (--spec.field_width > 0) {
2823 str = string(str, end, va_arg(args, char *), spec);
2828 spec);
2851 switch (spec.type) {
2862 if (spec.flags & SIGN)
2889 str = number(str, end, num, spec);
3060 struct printf_spec spec = {0};
3092 int read = format_decode(fmt, &spec);
3096 switch (spec.type) {
3108 set_field_width(&spec, width);
3148 spec);
3160 switch (spec.type) {
3219 struct printf_spec spec = {0};
3252 int read = format_decode(fmt, &spec);
3256 switch (spec.type) {
3269 set_field_width(&spec, get_arg(int));
3273 set_precision(&spec, get_arg(int));
3279 if (!(spec.flags & LEFT)) {
3280 while (--spec.field_width > 0) {
3290 while (--spec.field_width > 0) {
3301 str = string(str, end, (char *)str_arg, spec);
3333 str = pointer(fmt, str, end, get_arg(void *), spec);
3352 switch (spec.type) {
3386 str = number(str, end, num, spec);
3388 } /* switch(spec.type) */