(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c) |
| |
| 3212 | | | PRIVATE void emit_destructor_code(FILE *out, struct symbol *sp, struct lemon *lemp, |
| 3213 | | | int *lineno) |
| 3214 | | | { |
| 3215 | | | char *cp = 0; |
| 3216 | | | |
| 3217 | | | int linecnt = 0; |
| 3218 | | | if( sp->type==TERMINAL ){ |
| 3219 | | | cp = lemp->tokendest; |
| 3220 | | | if( cp==0 ) return; |
| 3221 | | | fprintf(out,"{\n"); (*lineno)++; |
| 3222 | | | }else if( sp->destructor ){ |
| 3223 | | | cp = sp->destructor; |
| 3224 | | | fprintf(out,"{\n"); (*lineno)++; |
| 3225 | | | tplt_linedir(out,sp->destLineno,lemp->outname); (*lineno)++; |
| 3226 | | | }else if( lemp->vardest ){ |
| 3227 | | | cp = lemp->vardest; |
| 3228 | | | if( cp==0 ) return; |
Redundant Condition
cp == 0 always evaluates to false. This may be because: - There is a constant assignment to one or more of the variables involved.
- An earlier conditional statement has already ensured that cp == 0 cannot be true.
- A crashing bug occurs on every path where cp == 0 could have evaluated to true. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 3229 | | | fprintf(out,"{\n"); (*lineno)++; |
| 3230 | | | }else{ |
| 3231 | | | assert( 0 );
x /usr/include/assert.h |
| |
91 | # define assert(expr) \ |
92 | ((expr) \ |
93 | ? __ASSERT_VOID_CAST (0) \ |
94 | : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)) |
| |
x /usr/include/assert.h |
| |
42 | # define __ASSERT_VOID_CAST (void) |
| |
x /usr/include/assert.h |
| |
109 | # define __ASSERT_FUNCTION __PRETTY_FUNCTION__ |
| |
|
| 3232 | | | } |
| 3233 | | | for(; *cp; cp++){ |
| 3234 | | | if( *cp=='$' && cp[1]=='$' ){ |
| 3235 | | | fprintf(out,"(yypminor->yy%d)",sp->dtnum); |
| 3236 | | | cp++; |
| 3237 | | | continue; |
| 3238 | | | } |
| 3239 | | | if( *cp=='\n' ) linecnt++; |
| 3240 | | | fputc(*cp,out); |
| 3241 | | | } |
| 3242 | | | (*lineno) += 3 + linecnt; |
| 3243 | | | fprintf(out,"\n"); |
| 3244 | | | tplt_linedir(out,*lineno,lemp->outname); |
| 3245 | | | fprintf(out,"}\n"); |
| 3246 | | | return; |
| 3247 | | | } |
| |