Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at tap-rpcstat.c:305

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

rpcstat_init

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tap-rpcstat.c)expand/collapse
Show more  
 271  rpcstat_init(const char *optarg, void* userdata _U_)
 272  {
 273          rpcstat_t *rs;
 274          guint32 i;
 275          int program, version;
 276          int pos=0;
 277          const char *filter=NULL;
 278          GString *error_string;
 279   
 280          if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){
 281                  if(pos){
 282                          filter=optarg+pos;
 283                  } else {
 284                          filter=NULL;
 285                  }
 286          } else {
 287                  fprintf(stderr, "tshark: invalid \"-z rpc,rtt,<program>,<version>[,<filter>]\" argument\n");
 288                  exit(1);
 289          }
 290   
 291          rs=g_malloc(sizeof(rpcstat_t));
 292          rs->prog=rpc_prog_name(program);
 293          rs->program=program;
 294          rs->version=version;
 295          if(filter){
 296                  rs->filter=g_strdup(filter);
 297          } else {
 298                  rs->filter=NULL;
 299          }
 300          rpc_program=program;
 301          rpc_version=version;
 302          rpc_min_proc=-1;
 303          rpc_max_proc=-1;
 304          g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL);
 305          if(rpc_min_proc==-1){
 306                  fprintf(stderr,"tshark: Invalid -z rpc,rrt,%d,%d\n",rpc_program,rpc_version);
 307                  fprintf(stderr,"   Program:%d version:%d isn't supported by tshark.\n", rpc_program, rpc_version);
 308                  exit(1);
 309          }
 310   
 311   
 312          rs->num_procedures=rpc_max_proc+1;
 313          rs->procedures=g_malloc(sizeof(rpc_procedure_t)*(rs->num_procedures+1));
 314          for(i=0;i<rs->num_procedures;i++){
 315                  rs->procedures[i].proc=rpc_proc_name(program, version, i);
 316                  rs->procedures[i].num=0;        
 317                  rs->procedures[i].min.secs=0;
 318                  rs->procedures[i].min.nsecs=0;
 319                  rs->procedures[i].max.secs=0;
 320                  rs->procedures[i].max.nsecs=0;
 321                  rs->procedures[i].tot.secs=0;
 322                  rs->procedures[i].tot.nsecs=0;
 323          }
 324   
 325  /* It is possible to create a filter and attach it to the callbacks. Then the
 326   * callbacks would only be invoked if the filter matched.
 327   * Evaluating filters is expensive and if we can avoid it and not use them
 328   * we gain performance.  
 329   * In this case we do the filtering for protocol and version inside the 
 330   * callback itself but use whatever filter the user provided.
 331   * (Perhaps the user only want the stats for nis+ traffic for certain objects?)
 332   *
 333   */
 334   
 335          error_string=register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw);
 336          if(error_string){
 337                  /* error, we failed to attach to the tap. clean up */
 338                  g_free(rs->procedures);
 339                  g_free(rs->filter);
 340                  g_free(rs);
 341   
 342                  fprintf(stderr, "tshark: Couldn't register rpc,rtt tap: %s\n",
 343                      error_string->str);
 344                  g_string_free(error_string, TRUE);
 345                  exit(1);
 346          }
 347  }
Show more  




Change Warning 4875.30912 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: