Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at supported_protos_dlg.c:337

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

set_supported_text

(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/supported_protos_dlg.c)expand/collapse
Show more  
 193  static void set_supported_text(GtkWidget *w, supported_type_t type)
 194  {
 195   
 196  #define BUFF_LEN 4096
 197  #define B_LEN    256 
 198    char buffer[BUFF_LEN];
 199    header_field_info *hfinfo;
 200    int i, len, maxlen = 0, maxlen2 = 0, maxlen4 = 0;
 201    const char *type_name;
 202    void *cookie, *cookie2;
 203    protocol_t *protocol;
 204    const char *name, *short_name, *filter_name;
 205    int namel = 0, short_namel = 0, filter_namel = 0;
 206    int count, fcount;
 207   
 208   
 209    /*
 210     * XXX quick hack:
 211     * the width and height computations are performed to make the
 212     * horizontal scrollbar work in gtk1.2. This is only necessary for the
 213     * PROTOCOL_SUPPORTED and DFILTER_SUPPORTED windows since all others should
 214     * not have any horizontal scrollbar (line wrapping enabled).
 215     */
 216   
 217   
 218    switch(type) {
 219   
 220    case PROTOCOL_SUPPORTED :
 221      /* first pass to know the maximum length of first field */
 222      count = 0;
 223      for (i = proto_get_first_protocol(&cookie); i != -1;
 224           i = proto_get_next_protocol(&cookie)) {
 225              count++;
 226              protocol = find_protocol_by_id(i);
 227              name = proto_get_protocol_name(i);
 228              short_name = proto_get_protocol_short_name(protocol);
 229              filter_name = proto_get_protocol_filter_name(i);
 230              if ((len = (int) strlen(name)) > namel)
 231                      namel = len;
 232              if ((len = (int) strlen(short_name)) > short_namel)
 233                      short_namel = len;
 234              if ((len = (int) strlen(filter_name)) > filter_namel)
 235                      filter_namel = len;
 236      }
 237      maxlen = namel + short_namel + filter_namel;
 238   
 239      len = g_snprintf(buffer, BUFF_LEN, proto_supported, count);
 240      insert_text(w, buffer, len);
 241   
 242      /* ok, display the correctly aligned strings */
 243      for (i = proto_get_first_protocol(&cookie); i != -1;
 244           i = proto_get_next_protocol(&cookie)) {
 245              protocol = find_protocol_by_id(i);
 246              name = proto_get_protocol_name(i);
 247              short_name = proto_get_protocol_short_name(protocol);
 248              filter_name = proto_get_protocol_filter_name(i);
 249   
 250              /* the name used for sorting in the left column */
 251              len = g_snprintf(buffer, BUFF_LEN, "%*s %*s %*s\n",
 252                             -short_namel,  short_name,
 253                             -namel,        name,
 254                             -filter_namel, filter_name);
 255              insert_text(w, buffer, (int) strlen(buffer));
 256      }
 257   
 258      break;
 259   
 260    case DFILTER_SUPPORTED  :
 261   
 262      /* XXX we should display hinfo->blurb instead of name (if not empty) */
 263   
 264      /* first pass to know the maximum length of first and second fields */
 265      for (i = proto_get_first_protocol(&cookie); i != -1;
 266           i = proto_get_next_protocol(&cookie)) {
 267   
 268              for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
 269                   hfinfo = proto_get_next_protocol_field(&cookie2)) {
 270   
 271                      if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
 272                              continue;
 273   
 274                      if ((len = (int) strlen(hfinfo->abbrev)) > maxlen)
 275                              maxlen = len;
 276                      if ((len = (int) strlen(hfinfo->name)) > maxlen2)
 277                              maxlen2 = len;
 278                      if (hfinfo->blurb != NULL) {
 279                              if ((len = (int) strlen(hfinfo->blurb)) > maxlen4)
 280                                  maxlen4 = len;
 281                      }
 282              }
 283      }
 284   
 285      insert_text(w, dfilter_supported, (int) strlen(dfilter_supported));
 286   
 287      fcount = 0;
 288      for (i = proto_get_first_protocol(&cookie); i != -1;
 289           i = proto_get_next_protocol(&cookie)) {
 290              protocol = find_protocol_by_id(i);
 291              name = proto_get_protocol_name(i);
 292              short_name = proto_get_protocol_short_name(protocol);
 293              filter_name = proto_get_protocol_filter_name(i);
 294   
 295              count = 0;
 296              for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
 297                   hfinfo = proto_get_next_protocol_field(&cookie2)) {
 298   
 299                      if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
 300                              continue;
 301                      count++;
 302              }
 303              fcount += count;
 304   
 305              len = g_snprintf(buffer, BUFF_LEN, "\n%s - %s (%s) [%d fields]:\n",
 306                             short_name, name, filter_name, count);
 307              insert_text(w, buffer, len);
 308   
 309              for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
 310                   hfinfo = proto_get_next_protocol_field(&cookie2)) {
 311   
 312                      if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
 313                              continue;
 314   
 315                      type_name = ftype_pretty_name(hfinfo->type);
 316                      if (hfinfo->blurb != NULL && hfinfo->blurb[0] != '\0') {
 317                              len = g_snprintf(buffer, BUFF_LEN, "%*s %*s %*s (%s)\n",
 318                                               -maxlen,  hfinfo->abbrev,
 319                                               -maxlen2, hfinfo->name,
 320                                               -maxlen4, hfinfo->blurb,
 321                                               type_name);
 322                      } else {
 323                              len = g_snprintf(buffer, BUFF_LEN, "%*s %*s (%s)\n",
 324                                               -maxlen,  hfinfo->abbrev,
 325                                               -maxlen2, hfinfo->name,
 326                                               type_name);
 327                      }
 328                      insert_text(w, buffer, (int) strlen(buffer));
 329              }
 330      }
 331      len = g_snprintf(buffer, BUFF_LEN, "\n-- Total %d fields\n", fcount);
 332      insert_text(w, buffer, len);
 333   
 334      break;
 335    default :
 336      g_assert_not_reached();
 337      break;
 338    } /* switch(type) */
 339  } /* set_supported_text */
Show more  




Change Warning 4222.30595 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: