Lines Matching refs:fmt

98 format_decode(const char *fmt, struct printf_spec *spec)  in format_decode()  argument
100 const char *start = fmt; in format_decode()
125 for (; *fmt ; ++fmt) { in format_decode()
126 if (*fmt == '%') in format_decode()
131 if (fmt != start || !*fmt) in format_decode()
132 return fmt - start; in format_decode()
140 ++fmt; in format_decode()
142 switch (*fmt) { in format_decode()
158 if (isdigit(*fmt)) in format_decode()
159 spec->field_width = skip_atoi(&fmt); in format_decode()
160 else if (*fmt == '*') { in format_decode()
163 return ++fmt - start; in format_decode()
169 if (*fmt == '.') { in format_decode()
170 ++fmt; in format_decode()
171 if (isdigit(*fmt)) { in format_decode()
172 spec->precision = skip_atoi(&fmt); in format_decode()
175 } else if (*fmt == '*') { in format_decode()
178 return ++fmt - start; in format_decode()
185 if (*fmt == 'h' || _tolower(*fmt) == 'l' || in format_decode()
186 _tolower(*fmt) == 'z' || *fmt == 't') { in format_decode()
187 qualifier = *fmt++; in format_decode()
188 if (qualifier == *fmt) { in format_decode()
191 ++fmt; in format_decode()
194 ++fmt; in format_decode()
196 sm_warning("invalid repeated qualifier '%c'", *fmt); in format_decode()
203 switch (*fmt) { in format_decode()
209 return ++fmt - start; in format_decode()
216 return ++fmt - start; in format_decode()
220 return ++fmt - start; in format_decode()
224 return ++fmt - start; in format_decode()
246 return ++fmt - start; in format_decode()
253 return ++fmt - start; in format_decode()
260 return ++fmt - start; in format_decode()
291 return ++fmt - start; in format_decode()
356 static void ip4(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in ip4() argument
360 assert(fmt[0] == 'i' || fmt[0] == 'I'); in ip4()
361 assert(fmt[1] == '4'); in ip4()
363 if (isalnum(fmt[2])) { in ip4()
364 switch (fmt[2]) { in ip4()
376 sm_warning("'%%p%c4' can only be followed by one of [hnbl], not '%c'", fmt[0], fmt[2]); in ip4()
378 if (isalnum(fmt[3])) in ip4()
379 sm_warning("'%%p%c4' can only be followed by precisely one of [hnbl]", fmt[0]); in ip4()
384 sm_error("passing __user pointer to '%%p%c4'", fmt[0]); in ip4()
400 sm_warning("passing struct in_addr* to '%%p%c4%c', is the endianness ok?", fmt[0], fmt[2]); in ip4()
405 static void ip6(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in ip6() argument
407 assert(fmt[0] == 'i' || fmt[0] == 'I'); in ip6()
408 assert(fmt[1] == '6'); in ip6()
410 if (isalnum(fmt[2])) { in ip6()
411 if (fmt[2] != 'c') in ip6()
412 sm_warning("'%%p%c6' can only be followed by c", fmt[0]); in ip6()
413 else if (fmt[0] == 'i') in ip6()
415 if (isalnum(fmt[3])) in ip6()
416 sm_warning("'%%p%c6%c' cannot be followed by other alphanumerics", fmt[0], fmt[2]); in ip6()
420 sm_error("passing __user pointer to '%%p%c6'", fmt[0]); in ip6()
423 static void ipS(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in ipS() argument
427 assert(tolower(fmt[0]) == 'i'); in ipS()
428 assert(fmt[1] == 'S'); in ipS()
430 for (f = fmt+2; isalnum(*f); ++f) { in ipS()
433 sm_warning("'%%p%cS' cannot be followed by '%c'", fmt[0], *f); in ipS()
449 "argument %d has type '%s'", fmt[0], vaidx, type_to_str(type)); in ipS()
452 static void hex_string(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in hex_string() argument
454 assert(fmt[0] == 'h'); in hex_string()
455 if (isalnum(fmt[1])) { in hex_string()
456 if (!strchr("CDN", fmt[1])) in hex_string()
457 sm_warning("'%%ph' cannot be followed by '%c'", fmt[1]); in hex_string()
458 if (isalnum(fmt[2])) in hex_string()
465 static void escaped_string(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in escaped_string() argument
467 assert(fmt[0] == 'E'); in escaped_string()
468 while (isalnum(*++fmt)) { in escaped_string()
469 if (!strchr("achnops", *fmt)) in escaped_string()
476 static void resource_string(const char *fmt, struct symbol *type, struct symbol *basetype, int vaid… in resource_string() argument
478 assert(tolower(fmt[0]) == 'r'); in resource_string()
481 "but argument %d has type '%s'", fmt[0], vaidx, type_to_str(type)); in resource_string()
483 if (isalnum(fmt[1])) in resource_string()
484 sm_warning("'%%p%c' cannot be followed by '%c'", fmt[0], fmt[1]); in resource_string()
487 static void mac_address_string(const char *fmt, struct symbol *type, struct symbol *basetype, int v… in mac_address_string() argument
489 assert(tolower(fmt[0]) == 'm'); in mac_address_string()
490 if (isalnum(fmt[1])) { in mac_address_string()
491 if (!(fmt[1] == 'F' || fmt[1] == 'R')) in mac_address_string()
492 sm_warning("'%%p%c' cannot be followed by '%c'", fmt[0], fmt[1]); in mac_address_string()
493 if (fmt[0] == 'm' && fmt[1] == 'F') in mac_address_string()
495 if (isalnum(fmt[2])) in mac_address_string()
496 sm_warning("'%%p%c%c' cannot be followed by other alphanumeric", fmt[0], fmt[1]); in mac_address_string()
501 fmt[0], vaidx, type_to_str(type)); in mac_address_string()
504 sm_error("passing __user pointer to '%%p%c'", fmt[0]); in mac_address_string()
507 static void dentry_file(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in dentry_file() argument
511 assert(tolower(fmt[0]) == 'd'); in dentry_file()
512 tag = fmt[0] == 'd' ? "dentry" : "file"; in dentry_file()
514 if (isalnum(fmt[1])) { in dentry_file()
515 if (!strchr("234", fmt[1])) in dentry_file()
516 sm_warning("'%%p%c' can only be followed by one of [234]", fmt[0]); in dentry_file()
517 if (isalnum(fmt[2])) in dentry_file()
518 sm_warning("'%%p%c%c' cannot be followed by '%c'", fmt[0], fmt[1], fmt[2]); in dentry_file()
523 fmt[0], tag, vaidx, type_to_str(type)); in dentry_file()
526 static void time_and_date(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in time_and_date() argument
528 assert(tolower(fmt[0]) == 't'); in time_and_date()
530 if (fmt[1] == 'R' && !is_struct_tag(basetype, "rtc_time")) in time_and_date()
535 static void check_clock(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in check_clock() argument
537 assert(fmt[0] == 'C'); in check_clock()
538 if (isalnum(fmt[1])) { in check_clock()
539 if (!strchr("nr", fmt[1])) in check_clock()
541 if (isalnum(fmt[2])) in check_clock()
542 sm_warning("'%%pC%c' cannot be followed by '%c'", fmt[1], fmt[2]); in check_clock()
549 static void va_format(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in va_format() argument
551 assert(fmt[0] == 'V'); in va_format()
552 if (isalnum(fmt[1])) in va_format()
558 static void netdev_feature(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in netdev_feature() argument
562 assert(fmt[0] == 'N'); in netdev_feature()
563 if (fmt[1] != 'F') { in netdev_feature()
567 if (isalnum(fmt[2])) in netdev_feature()
568 sm_warning("%%pNF cannot be followed by '%c'", fmt[2]); in netdev_feature()
578 static void address_val(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in address_val() argument
584 assert(fmt[0] == 'a'); in address_val()
586 if (isalnum(fmt[1])) { in address_val()
587 switch (fmt[1]) { in address_val()
598 if (isalnum(fmt[2])) in address_val()
599 sm_error("'%%pa%c' cannot be followed by '%c'", fmt[1], fmt[2]); in address_val()
611 static void block_device(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in block_device() argument
615 assert(fmt[0] == 'g'); in block_device()
616 if (isalnum(fmt[1])) { in block_device()
617 sm_warning("%%pg cannot be followed by '%c'", fmt[1]); in block_device()
621 fmt[0], tag, vaidx, type_to_str(type)); in block_device()
624 static void flag_string(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx) in flag_string() argument
628 assert(fmt[0] == 'G'); in flag_string()
629 if (!isalnum(fmt[1])) { in flag_string()
633 switch (fmt[1]) { in flag_string()
638 fmt[1], vaidx, type_to_str(type)); in flag_string()
651 static void device_node_string(const char *fmt, struct symbol *type, struct symbol *basetype, int v… in device_node_string() argument
653 if (fmt[1] != 'F') { in device_node_string()
663 pointer(const char *fmt, struct expression *arg, int vaidx) in pointer() argument
679 if (*fmt == 'e') in pointer()
680 fmt++; in pointer()
684 if (!isalnum(*fmt)) in pointer()
713 switch (*fmt) { in pointer()
725 resource_string(fmt, type, basetype, vaidx); in pointer()
729 mac_address_string(fmt, type, basetype, vaidx); in pointer()
733 switch (fmt[1]) { in pointer()
735 ip4(fmt, type, basetype, vaidx); in pointer()
738 ip6(fmt, type, basetype, vaidx); in pointer()
741 ipS(fmt, type, basetype, vaidx); in pointer()
744 sm_warning("'%%p%c' must be followed by one of [46S]", fmt[0]); in pointer()
754 escaped_string(fmt, type, basetype, vaidx); in pointer()
757 hex_string(fmt, type, basetype, vaidx); in pointer()
762 va_format(fmt, type, basetype, vaidx); in pointer()
767 netdev_feature(fmt, type, basetype, vaidx); in pointer()
770 address_val(fmt, type, basetype, vaidx); in pointer()
774 dentry_file(fmt, type, basetype, vaidx); in pointer()
777 time_and_date(fmt, type, basetype, vaidx); in pointer()
780 check_clock(fmt, type, basetype, vaidx); in pointer()
783 block_device(fmt, type, basetype, vaidx); in pointer()
786 flag_string(fmt, type, basetype, vaidx); in pointer()
789 device_node_string(fmt, type, basetype, vaidx); in pointer()
795 sm_error("unrecognized %%p extension '%c', treated as normal %%p", *fmt); in pointer()
808 hexbyte(const char *fmt, int fmt_len, struct expression *arg, int vaidx, struct printf_spec spec) in hexbyte() argument
828 vaidx, fmt_len, fmt, type_to_str(type)); in hexbyte()
832 check_format_string(const char *fmt, const char *caller) in check_format_string() argument
836 for (f = fmt; *f; ++f) { in check_format_string()
844 if (f != fmt) in check_format_string()
867 if (f == fmt) in check_format_string()
876 f = strstr(fmt, caller); in check_format_string()
984 check_cast_from_pointer(const char *fmt, int len, struct expression *arg, int va_idx) in check_cast_from_pointer() argument
997 va_idx, len, fmt); in check_cast_from_pointer()
1004 const char *fmt, *orig_fmt; in do_check_printf_call() local
1046 orig_fmt = fmt = fmtexpr->string->data; in do_check_printf_call()
1047 caller_in_fmt = check_format_string(fmt, caller); in do_check_printf_call()
1049 while (*fmt) { in do_check_printf_call()
1050 const char *old_fmt = fmt; in do_check_printf_call()
1051 int read = format_decode(fmt, &spec); in do_check_printf_call()
1054 fmt += read; in do_check_printf_call()
1074 old_fmt-2, (int)(fmt-old_fmt), old_fmt); in do_check_printf_call()
1128 pointer(fmt, arg, vaidx); in do_check_printf_call()
1129 while (isalnum(*fmt)) in do_check_printf_call()
1130 fmt++; in do_check_printf_call()
1144 hexbyte(old_fmt, fmt-old_fmt, arg, vaidx, spec); in do_check_printf_call()
1215 #define printf_hook(func, fmt, first_to_check) \ in check_kernel_printf() argument
1216 add_function_hook(#func, check_printf_call, INT_PTR(fmt + (first_to_check << 8))) in check_kernel_printf()