Print this page
11506 smatch resync


 504 
 505 static void dentry_file(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 506 {
 507         const char *tag;
 508 
 509         assert(tolower(fmt[0]) == 'd');
 510         tag = fmt[0] == 'd' ? "dentry" : "file";
 511 
 512         if (isalnum(fmt[1])) {
 513                 if (!strchr("234", fmt[1]))
 514                         sm_warning("'%%p%c' can only be followed by one of [234]", fmt[0]);
 515                 if (isalnum(fmt[2]))
 516                         sm_warning("'%%p%c%c' cannot be followed by '%c'", fmt[0], fmt[1], fmt[2]);
 517         }
 518 
 519         if (!is_struct_tag(basetype, tag))
 520                 sm_error("'%%p%c' expects argument of type struct '%s*', argument %d has type '%s'",
 521                         fmt[0], tag, vaidx, type_to_str(type));
 522 }
 523 









 524 static void check_clock(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 525 {
 526         assert(fmt[0] == 'C');
 527         if (isalnum(fmt[1])) {
 528                 if (!strchr("nr", fmt[1]))
 529                         sm_warning("'%%pC' can only be followed by one of [nr]");
 530                 if (isalnum(fmt[2]))
 531                         sm_warning("'%%pC%c' cannot be followed by '%c'", fmt[1], fmt[2]);
 532         }
 533         if (!is_struct_tag(basetype, "clk"))
 534                 sm_error("'%%pC' expects argument of type 'struct clk*', argument %d has type '%s'",
 535                        vaidx, type_to_str(type));
 536 }
 537 
 538 static void va_format(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 539 {
 540         assert(fmt[0] == 'V');
 541         if (isalnum(fmt[1]))
 542                 sm_warning("%%pV cannot be followed by any alphanumerics");
 543         if (!is_struct_tag(basetype, "va_format"))


 739         case 'h':
 740                 hex_string(fmt, type, basetype, vaidx);
 741                 break;
 742         case 'U': /* TODO */
 743                 break;
 744         case 'V':
 745                 va_format(fmt, type, basetype, vaidx);
 746                 break;
 747         case 'K': /* TODO */
 748                 break;
 749         case 'N':
 750                 netdev_feature(fmt, type, basetype, vaidx);
 751                 break;
 752         case 'a':
 753                 address_val(fmt, type, basetype, vaidx);
 754                 break;
 755         case 'D':
 756         case 'd':
 757                 dentry_file(fmt, type, basetype, vaidx);
 758                 break;



 759         case 'C':
 760                 check_clock(fmt, type, basetype, vaidx);
 761                 break;
 762         case 'g':
 763                 block_device(fmt, type, basetype, vaidx);
 764                 break;
 765         case 'G':
 766                 flag_string(fmt, type, basetype, vaidx);
 767                 break;
 768         case 'O':
 769                 device_node_string(fmt, type, basetype, vaidx);
 770                 break;
 771         case 'x':
 772                 /* 'x' is for an unhashed pointer */
 773                 break;
 774         default:
 775                 sm_error("unrecognized %%p extension '%c', treated as normal %%p", *fmt);
 776         }
 777 }
 778 




 504 
 505 static void dentry_file(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 506 {
 507         const char *tag;
 508 
 509         assert(tolower(fmt[0]) == 'd');
 510         tag = fmt[0] == 'd' ? "dentry" : "file";
 511 
 512         if (isalnum(fmt[1])) {
 513                 if (!strchr("234", fmt[1]))
 514                         sm_warning("'%%p%c' can only be followed by one of [234]", fmt[0]);
 515                 if (isalnum(fmt[2]))
 516                         sm_warning("'%%p%c%c' cannot be followed by '%c'", fmt[0], fmt[1], fmt[2]);
 517         }
 518 
 519         if (!is_struct_tag(basetype, tag))
 520                 sm_error("'%%p%c' expects argument of type struct '%s*', argument %d has type '%s'",
 521                         fmt[0], tag, vaidx, type_to_str(type));
 522 }
 523 
 524 static void time_and_date(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 525 {
 526         assert(tolower(fmt[0]) == 't');
 527 
 528         if (fmt[1] == 'R' && !is_struct_tag(basetype, "rtc_time"))
 529                 sm_error("'%%ptR' expects argument of type struct 'rtc_time', argument %d has type '%s'",
 530                          vaidx, type_to_str(type));
 531 }
 532 
 533 static void check_clock(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 534 {
 535         assert(fmt[0] == 'C');
 536         if (isalnum(fmt[1])) {
 537                 if (!strchr("nr", fmt[1]))
 538                         sm_warning("'%%pC' can only be followed by one of [nr]");
 539                 if (isalnum(fmt[2]))
 540                         sm_warning("'%%pC%c' cannot be followed by '%c'", fmt[1], fmt[2]);
 541         }
 542         if (!is_struct_tag(basetype, "clk"))
 543                 sm_error("'%%pC' expects argument of type 'struct clk*', argument %d has type '%s'",
 544                        vaidx, type_to_str(type));
 545 }
 546 
 547 static void va_format(const char *fmt, struct symbol *type, struct symbol *basetype, int vaidx)
 548 {
 549         assert(fmt[0] == 'V');
 550         if (isalnum(fmt[1]))
 551                 sm_warning("%%pV cannot be followed by any alphanumerics");
 552         if (!is_struct_tag(basetype, "va_format"))


 748         case 'h':
 749                 hex_string(fmt, type, basetype, vaidx);
 750                 break;
 751         case 'U': /* TODO */
 752                 break;
 753         case 'V':
 754                 va_format(fmt, type, basetype, vaidx);
 755                 break;
 756         case 'K': /* TODO */
 757                 break;
 758         case 'N':
 759                 netdev_feature(fmt, type, basetype, vaidx);
 760                 break;
 761         case 'a':
 762                 address_val(fmt, type, basetype, vaidx);
 763                 break;
 764         case 'D':
 765         case 'd':
 766                 dentry_file(fmt, type, basetype, vaidx);
 767                 break;
 768         case 't':
 769                 time_and_date(fmt, type, basetype, vaidx);
 770                 break;
 771         case 'C':
 772                 check_clock(fmt, type, basetype, vaidx);
 773                 break;
 774         case 'g':
 775                 block_device(fmt, type, basetype, vaidx);
 776                 break;
 777         case 'G':
 778                 flag_string(fmt, type, basetype, vaidx);
 779                 break;
 780         case 'O':
 781                 device_node_string(fmt, type, basetype, vaidx);
 782                 break;
 783         case 'x':
 784                 /* 'x' is for an unhashed pointer */
 785                 break;
 786         default:
 787                 sm_error("unrecognized %%p extension '%c', treated as normal %%p", *fmt);
 788         }
 789 }
 790