Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at prefs.c:819

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

prefs_get_string_list

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/prefs.c)expand/collapse
Show more  
 806  GList *
 807  prefs_get_string_list(gchar *str)
 808  {
 809    enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT };
 810   
 811    gint      state = PRE_STRING, i = 0, j = 0;
 812    gboolean  backslash = FALSE;
 813    guchar    cur_c;
 814    gchar    *slstr = NULL;
 815    GList    *sl = NULL;
 816   
 817    /* Allocate a buffer for the first string.   */
 818    slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
 819    j = 0;
 820   
 821    for (;;) {
 822      cur_c = str[i];
 823      if (cur_c == '\0') {
 824        /* It's the end of the input, so it's the end of the string we
 825           were working on, and there's no more input. */
 826        if (state == IN_QUOT || backslash) {
 827          /* We were in the middle of a quoted string or backslash escape,
 828             and ran out of characters; that's an error.  */
 829          g_free(slstr);
 830          prefs_clear_string_list(sl);
 831          return NULL;
 832        }
 833        slstr[j] = '\0';
 834        sl = g_list_append(sl, slstr);
 835        break;
 836      }
 837      if (cur_c == '"' && ! backslash) {
 838        switch (state) {
 839          case PRE_STRING:
 840            /* We hadn't yet started processing a string; this starts the 
 841               string, and we're now quoting.  */
 842            state = IN_QUOT;
 843            break;
 844          case IN_QUOT:
 845            /* We're in the middle of a quoted string, and we saw a quotation 
 846               mark; we're no longer quoting.   */
 847            state = NOT_IN_QUOT;
 848            break;
 849          case NOT_IN_QUOT:
 850            /* We're working on a string, but haven't seen a quote; we're
 851               now quoting.  */
 852            state = IN_QUOT;
 853            break;
 854          default:
 855            break;
 856        }
 857      } else if (cur_c == '\\' && ! backslash) {
 858        /* We saw a backslash, and the previous character wasn't a 
 859           backslash; escape the next character.
 860   
 861           This also means we've started a new string. */
 862        backslash = TRUE;
 863        if (state == PRE_STRING)
 864          state = NOT_IN_QUOT;
 865      } else if (cur_c == ',' && state != IN_QUOT && ! backslash) {
 866        /* We saw a comma, and we're not in the middle of a quoted string
 867           and it wasn't preceded by a backslash; it's the end of 
 868           the string we were working on...  */
 869        slstr[j] = '\0';
 870        sl = g_list_append(sl, slstr);
 871   
 872        /* ...and the beginning of a new string.  */
 873        state = PRE_STRING;
 874        slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
 875        j = 0;
 876      } else if (!isspace(cur_c) || state != PRE_STRING) {
 877        /* Either this isn't a white-space character, or we've started a
 878           string (i.e., already seen a non-white-space character for that 
 879           string and put it into the string).
 880   
 881           The character is to be put into the string; do so if there's
 882           room.  */
 883        if (j < COL_MAX_LEN) {
 884          slstr[j] = cur_c;
 885          j++;
 886        }
 887   
 888        /* If it was backslash-escaped, we're done with the backslash escape.  */
 889        backslash = FALSE;
 890      }
 891      i++;
 892    }
 893    return(sl);
 894  }
Show more  




Change Warning 3491.29639 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: