Text   |  XML   |  ReML   |   Visible Warnings:

Uninitialized Variable  at lemon.c:3742

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

main

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 1444  int main(int argc _U_, char **argv)
 1445  {
 1446    static int version = 0;
 1447    static int rpflag = 0;
 1448    static int basisflag = 0;
 1449    static int compress = 0;
 1450    static int quiet = 0;
 1451    static int statistics = 0;
 1452    static int mhflag = 0;
 1453    static char *outdirname = NULL;
 1454    static char *templatename = NULL;
 1455    static struct s_options options[] = {
 1456      {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."},
 1457      {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
 1458      {OPT_STR,  "d", (char*)&outdirname, "Output directory name."},
 1459      {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
 1460      {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
 1461      {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file"},
 1462      {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},
 1463      {OPT_FLAG, "s", (char*)&statistics,
 1464                                     "Print parser stats to standard output."},
 1465      {OPT_STR,  "t", (char*)&templatename, "Template file to use."},
 1466      {OPT_FLAG, "x", (char*)&version, "Print the version number."},
 1467      {OPT_FLAG,0,0,0}
 1468    };
 1469    int i;
 1470    struct lemon lem;
 1471   
 1472    optinit(argv,options,stderr);
 1473    if( version ){
 1474       printf("Lemon version 1.0\n"
 1475         "Copyright 1991-1997 by D. Richard Hipp\n"
 1476         "Freely distributable under the GNU Public License.\n"
 1477       );
 1478       exit(0);
 1479    }
 1480[+]   if( optnargs()!=1 ){
 1481      fprintf(stderr,"Exactly one filename argument is required.\n");
 1482      exit(1);
 1483    }
 1484    memset(&lem, 0, sizeof(lem));
 1485    lem.errorcnt = 0;
 1486   
 1487    /* Initialize the machine */
 1488    Strsafe_init();
 1489    Symbol_init();
 1490    State_init();
 1491    lem.argv0 = argv[0];
 1492    lem.filename = get_optarg(0);
 1493    lem.basisflag = basisflag;
 1494    Symbol_new("$");
 1495    lem.errsym = Symbol_new("error");
 1496    /*
 1497    **  Resetting useCnt in errsym seems to disable some error checking we  
 1498    **  need to validate the filter syntax.  So we remove this resetting for now.
 1499    **
 1500    **  lem.errsym->useCnt = 0;
 1501    */
 1502    lem.outdirname = outdirname;
 1503    lem.templatename = templatename;
 1504    lem.basename = make_basename(lem.filename);
 1505   
 1506    /* Parse the input file */
 1507[+]   Parse(&lem);
 1508    if( lem.errorcnt ) exit(lem.errorcnt);
 1509    if( lem.nrule==0 ){
 1510      fprintf(stderr,"Empty grammar.\n");
 1511      exit(1);
 1512    }
 1513   
 1514    /* Count and index the symbols of the grammar */
 1515    lem.nsymbol = Symbol_count();
 1516    Symbol_new("{default}");
 1517    lem.symbols = Symbol_arrayof();
 1518    for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i;
 1519    qsort(lem.symbols,lem.nsymbol+1,sizeof(struct symbol*),
 1520          Symbolcmpp);
 1521    for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i;
 1522    for(i=1; safe_isupper(lem.symbols[i]->name[0]); i++);
 1523    lem.nterminal = i;
 1524   
 1525    /* Generate a reprint of the grammar, if requested on the command line */
 1526    if( rpflag ){
 1527      Reprint(&lem);
 1528    }else{
 1529      /* Initialize the size for all follow and first sets */
 1530      SetSize(lem.nterminal+1);
 1531   
 1532      /* Find the precedence for every production rule (that has one) */
 1533      FindRulePrecedences(&lem);
 1534   
 1535      /* Compute the lambda-nonterminals and the first-sets for every
 1536      ** nonterminal */
 1537      FindFirstSets(&lem);
 1538   
 1539      /* Compute all LR(0) states.  Also record follow-set propagation 
 1540      ** links so that the follow-set can be computed later */
 1541      lem.nstate = 0;
 1542      FindStates(&lem);
 1543[+]     lem.sorted = State_arrayof();
 1544   
 1545      /* Tie up loose ends on the propagation links */
 1546      FindLinks(&lem);
 1547   
 1548      /* Compute the follow set of every reducible configuration */
 1549      FindFollowSets(&lem);
 1550   
 1551      /* Compute the action tables */
 1552      FindActions(&lem);
 1553   
 1554      /* Compress the action tables */
 1555      if( compress==0 ) CompressTables(&lem);
 1556   
 1557      /* Reorder and renumber the states so that states with fewer choices 
 1558      ** occur at the end. */
 1559      ResortStates(&lem);
 1560   
 1561      /* Generate a report of the parser generated.  (the "y.output" file) */
 1562      if( !quiet ) ReportOutput(&lem);
 1563   
 1564      /* Generate the source code for the parser */
 1565[+]     ReportTable(&lem, mhflag);
expand/collapse

ReportTable

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 3620  void ReportTable(
 3621      struct lemon *lemp,
 3622      int mhflag)     /* Output in makeheaders format if true */
 3623  {
 3624    FILE *out, *in;
 3625    char line[LINESIZE];
 3626    int  lineno;
 3627    struct state *stp;
 3628    struct action *ap;
 3629    struct rule *rp;
 3630    struct acttab *pActtab;
 3631    int i, j, n;
 3632    const char *name;
 3633    int mnTknOfst, mxTknOfst;
 3634    int mnNtOfst, mxNtOfst;
 3635    struct axset *ax;
 3636   
 3637[+]   in = tplt_open(lemp);
 3638    if( in==0 ) return;
 3639[+]   out = file_open(lemp,".c","wb");
 3640    if( out==0 ){
 3641      fclose(in);
 3642      return;
 3643    }
 3644    lineno = 1;
 3645    tplt_xfer(lemp->name,in,out,&lineno);
 3646   
 3647    /* Generate the include code, if any */
 3648    tplt_print(out,lemp,lemp->include,&lineno);
 3649    if( mhflag ){
 3650      char *name = file_makename_using_basename(lemp, ".h");
 3651      fprintf(out,"#include \"%s\"\n", name); lineno++;
 3652      free(name);
 3653    }
 3654    tplt_xfer(lemp->name,in,out,&lineno);
 3655   
 3656    /* Generate #defines for all tokens */
 3657    if( mhflag ){
 3658      const char *prefix;
 3659      fprintf(out,"#if INTERFACE\n"); lineno++;
 3660      if( lemp->tokenprefix ) prefix = lemp->tokenprefix;
 3661      else                    prefix = "";
 3662      for(i=1; i<lemp->nterminal; i++){
 3663        fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);
 3664        lineno++;
 3665      }
 3666      fprintf(out,"#endif\n"); lineno++;
 3667    }
 3668    tplt_xfer(lemp->name,in,out,&lineno);
 3669   
 3670    /* Generate the defines */
 3671    fprintf(out,"#define YYCODETYPE %s\n",
 3672      minimum_signed_size_type(0, lemp->nsymbol+5)); lineno++;
 3673    fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1);  lineno++;
 3674    fprintf(out,"#define YYACTIONTYPE %s\n",
 3675      minimum_signed_size_type(0, lemp->nstate+lemp->nrule+5));  lineno++;
 3676    if( lemp->wildcard ){
 3677      fprintf(out,"#define YYWILDCARD %d\n",
 3678         lemp->wildcard->index); lineno++;
 3679    }
 3680    print_stack_union(out,lemp,&lineno,mhflag);
 3681    fprintf(out, "#ifndef YYSTACKDEPTH\n"); lineno++;
 3682    if( lemp->stacksize ){
 3683      fprintf(out,"#define YYSTACKDEPTH %s\n",lemp->stacksize);  lineno++;
 3684    }else{
 3685      fprintf(out,"#define YYSTACKDEPTH 100\n");  lineno++;
 3686    }
 3687    fprintf(out, "#endif\n"); lineno++;
 3688    if( mhflag ){
 3689      fprintf(out,"#if INTERFACE\n"); lineno++;
 3690    }
 3691    name = lemp->name ? lemp->name : "Parse";
 3692    if( lemp->arg && lemp->arg[0] ){
 3693      int i;
 3694      i = (int) strlen(lemp->arg);
 3695      while( i>=1 && safe_isspace(lemp->arg[i-1]) ) i--;
 3696      while( i>=1 && (safe_isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
 3697      fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg);  lineno++;
 3698      fprintf(out,"#define %sARG_PDECL ,%s\n",name,lemp->arg);  lineno++;
 3699      fprintf(out,"#define %sARG_FETCH %s = yypParser->%s\n",
 3700                   name,lemp->arg,&lemp->arg[i]);  lineno++;
 3701      fprintf(out,"#define %sARG_STORE yypParser->%s = %s\n",
 3702                   name,&lemp->arg[i],&lemp->arg[i]);  lineno++;
 3703    }else{
 3704      fprintf(out,"#define %sARG_SDECL\n",name);  lineno++;
 3705      fprintf(out,"#define %sARG_PDECL\n",name);  lineno++;
 3706      fprintf(out,"#define %sARG_FETCH\n",name); lineno++;
 3707      fprintf(out,"#define %sARG_STORE\n",name); lineno++;
 3708    }
 3709    if( mhflag ){
 3710      fprintf(out,"#endif\n"); lineno++;
 3711    }
 3712    fprintf(out,"#define YYNSTATE %d\n",lemp->nstate);  lineno++;
 3713    fprintf(out,"#define YYNRULE %d\n",lemp->nrule);  lineno++;
 3714    if( lemp->errsym->useCnt ){
 3715      fprintf(out,"#define YYERRORSYMBOL %d\n",lemp->errsym->index);  lineno++;
 3716      fprintf(out,"#define YYERRSYMDT yy%d\n",lemp->errsym->dtnum);  lineno++;
 3717    }
 3718    if( lemp->has_fallback ){
 3719      fprintf(out,"#define YYFALLBACK 1\n");  lineno++;
 3720    }
 3721    tplt_xfer(lemp->name,in,out,&lineno);
 3722   
 3723    /* Generate the action table and its associates:
 3724    **
 3725    **  yy_action[]        A single table containing all actions.
 3726    **  yy_lookahead[]     A table containing the lookahead for each entry in 
 3727    **                     yy_action.  Used to detect hash collisions.
 3728    **  yy_shift_ofst[]    For each state, the offset into yy_action for 
 3729    **                     shifting terminals.
 3730    **  yy_reduce_ofst[]   For each state, the offset into yy_action for 
 3731    **                     shifting non-terminals after a reduce.
 3732    **  yy_default[]       Default action for each state.
 3733    */
 3734   
 3735    /* Compute the actions on all states and count them up */
 3736    ax = calloc(lemp->nstate*2, sizeof(ax[0]));
 3737    if( ax==0 ){
 3738      fprintf(stderr,"malloc failed\n");
 3739      exit(1);
 3740    }
 3741    for(i=0; i<lemp->nstate; i++){
 3742      stp = lemp->sorted[i];
Show more  
Show more  




Change Warning 942.30689 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: