Lines Matching defs:spec
449 struct printf_spec spec)
455 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
458 int field_width = spec.field_width;
459 int precision = spec.precision;
463 locase = (spec.flags & SMALL);
464 if (spec.flags & LEFT)
465 spec.flags &= ~ZEROPAD;
467 if (spec.flags & SIGN) {
472 } else if (spec.flags & PLUS) {
475 } else if (spec.flags & SPACE) {
481 if (spec.base == 16)
489 if (num < spec.base)
491 else if (spec.base != 10) { /* 8 or 16 */
492 int mask = spec.base - 1;
495 if (spec.base == 16)
510 if (!(spec.flags & (ZEROPAD | LEFT))) {
525 if (spec.base == 16 || !is_zero) {
530 if (spec.base == 16) {
537 if (!(spec.flags & LEFT)) {
538 char c = ' ' + (spec.flags & ZEROPAD);
571 struct printf_spec spec;
573 spec.type = FORMAT_TYPE_PTR;
574 spec.field_width = 2 + 2 * size; /* 0x + hex */
575 spec.flags = SPECIAL | SMALL | ZEROPAD;
576 spec.base = 16;
577 spec.precision = -1;
579 return number(buf, end, num, spec);
605 * @spec: for field width and flags
609 char *widen_string(char *buf, int n, char *end, struct printf_spec spec)
613 if (likely(n >= spec.field_width))
616 spaces = spec.field_width - n;
617 if (!(spec.flags & LEFT)) {
631 struct printf_spec spec)
634 int lim = spec.precision;
645 return widen_string(buf, len, end, spec);
649 struct printf_spec spec)
655 return string_nocheck(buf, end, sym, spec);
662 spec.flags |= SIGN;
663 spec.base = 10;
664 return number(buf, end, err, spec);
669 struct printf_spec spec)
676 if (spec.precision == -1)
677 spec.precision = 2 * sizeof(void *);
679 return string_nocheck(buf, end, s, spec);
699 struct printf_spec spec)
705 *buf = error_string(*buf, end, err_msg, spec);
714 struct printf_spec spec)
716 if (check_pointer(&buf, end, s, spec))
719 return string_nocheck(buf, end, s, spec);
724 struct printf_spec spec)
726 spec.base = 16;
727 spec.flags |= SMALL;
728 if (spec.field_width == -1) {
729 spec.field_width = 2 * sizeof(ptr);
730 spec.flags |= ZEROPAD;
733 return number(buf, end, (unsigned long int)ptr, spec);
823 struct printf_spec spec)
834 return pointer_string(buf, end, ptr, spec);
839 return pointer_string(buf, end, (const void *)hashval, spec);
844 spec.field_width = 2 * sizeof(ptr);
846 return error_string(buf, end, str, spec);
849 return pointer_string(buf, end, (const void *)hashval, spec);
856 struct printf_spec spec)
861 return ptr_to_id(buf, end, ptr, spec);
870 if (spec.field_width == -1)
871 spec.field_width = 2 * sizeof(ptr);
872 return error_string(buf, end, "pK-error", spec);
898 return pointer_string(buf, end, ptr, spec);
902 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec,
920 if (check_pointer(&buf, end, d, spec)) {
935 for (n = 0; n != spec.precision; n++, buf++) {
947 return widen_string(buf, n, end, spec);
952 struct printf_spec spec, const char *fmt)
954 if (check_pointer(&buf, end, f, spec))
957 return dentry_name(buf, end, f->f_path.dentry, spec, fmt);
962 struct printf_spec spec, const char *fmt)
966 if (check_pointer(&buf, end, bdev, spec))
970 buf = string(buf, end, hd->disk_name, spec);
977 buf = number(buf, end, bdev->bd_partno, spec);
985 struct printf_spec spec, const char *fmt)
1004 return string_nocheck(buf, end, sym, spec);
1042 struct printf_spec spec, const char *fmt)
1088 if (check_pointer(&buf, end, res, spec))
1138 return string_nocheck(buf, end, sym, spec);
1142 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1149 if (spec.field_width == 0)
1153 if (check_pointer(&buf, end, addr, spec))
1171 if (spec.field_width > 0)
1172 len = min_t(int, spec.field_width, 64);
1194 struct printf_spec spec, const char *fmt)
1197 int nr_bits = max_t(int, spec.field_width, 0);
1201 if (check_pointer(&buf, end, bitmap, spec))
1205 spec = (struct printf_spec){ .flags = SMALL | ZEROPAD, .base = 16 };
1228 spec.field_width = DIV_ROUND_UP(chunksz, 4);
1229 buf = number(buf, end, val, spec);
1238 struct printf_spec spec, const char *fmt)
1240 int nr_bits = max_t(int, spec.field_width, 0);
1245 if (check_pointer(&buf, end, bitmap, spec))
1278 struct printf_spec spec, const char *fmt)
1286 if (check_pointer(&buf, end, addr, spec))
1314 return string_nocheck(buf, end, mac_addr, spec);
1468 struct printf_spec spec, const char *fmt)
1477 return string_nocheck(buf, end, ip6_addr, spec);
1482 struct printf_spec spec, const char *fmt)
1488 return string_nocheck(buf, end, ip4_addr, spec);
1493 struct printf_spec spec, const char *fmt)
1537 p = number(p, pend, ntohs(sa->sin6_port), spec);
1542 IPV6_FLOWINFO_MASK), spec);
1546 p = number(p, pend, sa->sin6_scope_id, spec);
1550 return string_nocheck(buf, end, ip6_addr, spec);
1555 struct printf_spec spec, const char *fmt)
1581 p = number(p, pend, ntohs(sa->sin_port), spec);
1585 return string_nocheck(buf, end, ip4_addr, spec);
1590 struct printf_spec spec, const char *fmt)
1594 if (check_pointer(&buf, end, ptr, spec))
1599 return ip6_addr_string(buf, end, ptr, spec, fmt);
1601 return ip4_addr_string(buf, end, ptr, spec, fmt);
1611 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt);
1613 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt);
1615 return error_string(buf, end, "(einval)", spec);
1620 return error_string(buf, end, err_fmt_msg, spec);
1624 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1632 if (spec.field_width == 0)
1635 if (check_pointer(&buf, end, addr, spec))
1670 len = spec.field_width < 0 ? 1 : spec.field_width;
1683 struct printf_spec spec, const char *fmt)
1687 if (check_pointer(&buf, end, va_fmt, spec))
1699 struct printf_spec spec, const char *fmt)
1707 if (check_pointer(&buf, end, addr, spec))
1739 return string_nocheck(buf, end, uuid, spec);
1744 struct printf_spec spec, const char *fmt)
1749 if (check_pointer(&buf, end, addr, spec))
1758 return error_string(buf, end, "(%pN?)", spec);
1766 struct printf_spec spec, const char *fmt)
1771 if (check_pointer(&buf, end, addr, spec))
1826 struct printf_spec spec, const char *fmt)
1832 if (check_pointer(&buf, end, tm, spec))
1864 struct printf_spec spec, const char *fmt)
1882 return rtc_str(buf, end, &rtc_time, spec, fmt);
1886 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
1891 return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
1893 return time64_str(buf, end, *(const time64_t *)ptr, spec, fmt);
1895 return error_string(buf, end, "(%pt?)", spec);
1900 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
1904 return error_string(buf, end, "(%pC?)", spec);
1906 if (check_pointer(&buf, end, clk, spec))
1913 return string(buf, end, __clk_get_name(clk), spec);
1915 return ptr_to_id(buf, end, clk, spec);
1949 struct printf_spec spec, const char *fmt)
1954 if (check_pointer(&buf, end, flags_ptr, spec))
1973 return error_string(buf, end, "(%pG?)", spec);
2008 struct printf_spec spec, const char *fmt)
2017 struct printf_spec str_spec = spec;
2021 return error_string(buf, end, "(%pO?)", spec);
2024 return error_string(buf, end, "(%pOF?)", spec);
2026 if (check_pointer(&buf, end, dn, spec))
2057 case 'P': /* path-spec */
2093 return widen_string(buf, buf - buf_start, end, spec);
2098 struct printf_spec spec, const char *fmt)
2100 struct printf_spec str_spec = spec;
2106 return error_string(buf, end, "(%pf?)", spec);
2108 if (check_pointer(&buf, end, fwnode, spec))
2123 return widen_string(buf, buf - buf_start, end, spec);
2227 * P device node path spec (name + @unit)
2249 struct printf_spec spec)
2257 return symbol_string(buf, end, ptr, spec, fmt);
2260 return resource_string(buf, end, ptr, spec, fmt);
2262 return hex_string(buf, end, ptr, spec, fmt);
2266 return bitmap_list_string(buf, end, ptr, spec, fmt);
2268 return bitmap_string(buf, end, ptr, spec, fmt);
2274 return mac_address_string(buf, end, ptr, spec, fmt);
2284 return ip_addr_string(buf, end, ptr, spec, fmt);
2286 return escaped_string(buf, end, ptr, spec, fmt);
2288 return uuid_string(buf, end, ptr, spec, fmt);
2290 return va_format(buf, end, ptr, spec, fmt);
2292 return restricted_pointer(buf, end, ptr, spec);
2294 return netdev_bits(buf, end, ptr, spec, fmt);
2296 return address_val(buf, end, ptr, spec, fmt);
2298 return dentry_name(buf, end, ptr, spec, fmt);
2300 return time_and_date(buf, end, ptr, spec, fmt);
2302 return clock(buf, end, ptr, spec, fmt);
2304 return file_dentry_name(buf, end, ptr, spec, fmt);
2307 return bdev_name(buf, end, ptr, spec, fmt);
2311 return flags_string(buf, end, ptr, spec, fmt);
2313 return device_node_string(buf, end, ptr, spec, fmt + 1);
2315 return fwnode_string(buf, end, ptr, spec, fmt + 1);
2317 return pointer_string(buf, end, ptr, spec);
2322 return err_ptr(buf, end, ptr, spec);
2327 return string(buf, end, ptr, spec);
2329 return error_string(buf, end, "(einval)", spec);
2334 return ptr_to_id(buf, end, ptr, spec);
2359 int format_decode(const char *fmt, struct printf_spec *spec)
2365 if (spec->type == FORMAT_TYPE_WIDTH) {
2366 if (spec->field_width < 0) {
2367 spec->field_width = -spec->field_width;
2368 spec->flags |= LEFT;
2370 spec->type = FORMAT_TYPE_NONE;
2375 if (spec->type == FORMAT_TYPE_PRECISION) {
2376 if (spec->precision < 0)
2377 spec->precision = 0;
2379 spec->type = FORMAT_TYPE_NONE;
2384 spec->type = FORMAT_TYPE_NONE;
2396 spec->flags = 0;
2404 case '-': spec->flags |= LEFT; break;
2405 case '+': spec->flags |= PLUS; break;
2406 case ' ': spec->flags |= SPACE; break;
2407 case '#': spec->flags |= SPECIAL; break;
2408 case '0': spec->flags |= ZEROPAD; break;
2417 spec->field_width = -1;
2420 spec->field_width = skip_atoi(&fmt);
2423 spec->type = FORMAT_TYPE_WIDTH;
2429 spec->precision = -1;
2433 spec->precision = skip_atoi(&fmt);
2434 if (spec->precision < 0)
2435 spec->precision = 0;
2438 spec->type = FORMAT_TYPE_PRECISION;
2461 spec->base = 10;
2464 spec->type = FORMAT_TYPE_CHAR;
2468 spec->type = FORMAT_TYPE_STR;
2472 spec->type = FORMAT_TYPE_PTR;
2476 spec->type = FORMAT_TYPE_PERCENT_CHAR;
2481 spec->base = 8;
2485 spec->flags |= SMALL;
2489 spec->base = 16;
2494 spec->flags |= SIGN;
2508 spec->type = FORMAT_TYPE_INVALID;
2513 spec->type = FORMAT_TYPE_LONG_LONG;
2516 spec->type = FORMAT_TYPE_ULONG + (spec->flags & SIGN);
2518 spec->type = FORMAT_TYPE_SIZE_T;
2520 spec->type = FORMAT_TYPE_PTRDIFF;
2523 spec->type = FORMAT_TYPE_UBYTE + (spec->flags & SIGN);
2526 spec->type = FORMAT_TYPE_USHORT + (spec->flags & SIGN);
2529 spec->type = FORMAT_TYPE_UINT + (spec->flags & SIGN);
2536 set_field_width(struct printf_spec *spec, int width)
2538 spec->field_width = width;
2539 if (WARN_ONCE(spec->field_width != width, "field width %d too large", width)) {
2540 spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX);
2545 set_precision(struct printf_spec *spec, int prec)
2547 spec->precision = prec;
2548 if (WARN_ONCE(spec->precision != prec, "precision %d too large", prec)) {
2549 spec->precision = clamp(prec, 0, PRECISION_MAX);
2585 struct printf_spec spec = {0};
2603 int read = format_decode(fmt, &spec);
2607 switch (spec.type) {
2620 set_field_width(&spec, va_arg(args, int));
2624 set_precision(&spec, va_arg(args, int));
2630 if (!(spec.flags & LEFT)) {
2631 while (--spec.field_width > 0) {
2642 while (--spec.field_width > 0) {
2651 str = string(str, end, va_arg(args, char *), spec);
2656 spec);
2679 switch (spec.type) {
2690 if (spec.flags & SIGN)
2717 str = number(str, end, num, spec);
2886 struct printf_spec spec = {0};
2918 int read = format_decode(fmt, &spec);
2922 switch (spec.type) {
2934 set_field_width(&spec, width);
2974 spec);
2986 switch (spec.type) {
3045 struct printf_spec spec = {0};
3078 int read = format_decode(fmt, &spec);
3082 switch (spec.type) {
3095 set_field_width(&spec, get_arg(int));
3099 set_precision(&spec, get_arg(int));
3105 if (!(spec.flags & LEFT)) {
3106 while (--spec.field_width > 0) {
3116 while (--spec.field_width > 0) {
3127 str = string(str, end, (char *)str_arg, spec);
3159 str = pointer(fmt, str, end, get_arg(void *), spec);
3178 switch (spec.type) {
3212 str = number(str, end, num, spec);
3214 } /* switch(spec.type) */