(/home/sate/Testcases/c/cve/wireshark-1.2.0/disabled_protos.c) |
| |
| 166 | | | read_disabled_protos_list_file(const char *ff_path, FILE *ff, |
| 167 | | | GList **flp) |
| 168 | | | { |
| 169 | | | protocol_def *prot; |
| 170 | | | int c; |
| 171 | | | char *prot_name; |
| 172 | | | int prot_name_len; |
| 173 | | | int prot_name_index; |
| 174 | | | int line = 1; |
| 175 | | | |
| 176 | | | |
| 177 | | | |
| 178 | | | prot_name_len = INIT_BUF_SIZE; |
| 179 | | | prot_name = g_malloc(prot_name_len + 1); |
| 180 | | | |
| 181 | | | for (line = 1; ; line++) { |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 182 | | | |
| 183 | | | |
| 184 | | | |
| 185 | | | |
| 186 | | | while ((c = getc(ff)) != EOF && isspace(c)) { |
| 187 | | | if (c == '\n') { |
| 188 | | | |
| 189 | | | continue; |
| 190 | | | } |
| 191 | | | } |
| 192 | | | |
| 193 | | | if (c == EOF) { |
| 194 | | | if (ferror(ff)) |
| 195 | | | goto error; |
| 196 | | | else |
| 197 | | | break; |
| 198 | | | } |
| 199 | | | ungetc(c, ff); |
| 200 | | | |
| 201 | | | |
| 202 | | | prot_name_index = 0; |
| 203 | | | for (;;) { |
| 204 | | | c = getc(ff); |
| 205 | | | if (c == EOF) |
| 206 | | | break; |
| 207 | | | if (isspace(c)) |
| 208 | | | break; |
| 209 | | | if (c == '#') |
| 210 | | | break; |
| 211 | | | |
| 212 | | | if (prot_name_index >= prot_name_len) { |
| 213 | | | |
| 214 | | | prot_name_len *= 2; |
| 215 | | | prot_name = g_realloc(prot_name, prot_name_len + 1); |
| 216 | | | } |
| 217 | | | prot_name[prot_name_index] = c; |
| 218 | | | prot_name_index++; |
| 219 | | | } |
| 220 | | | |
| 221 | | | if (isspace(c) && c != '\n') { |
| 222 | | | |
| 223 | | | while ((c = getc(ff)) != EOF && c != '\n' && isspace(c)) |
| 224 | | | ; |
| 225 | | | if (c != EOF && c != '\n' && c != '#') { |
| 226 | | | |
| 227 | | | |
| 228 | | | g_warning("'%s' line %d has stuff after the protocol name.",
x /usr/include/glib-2.0/glib/gmessages.h |
| |
153 | #define g_warning(...) g_log (G_LOG_DOMAIN, \ |
154 | G_LOG_LEVEL_WARNING, \ |
155 | __VA_ARGS__) |
| |
|
| 229 | | | ff_path, line); |
| 230 | | | } |
| 231 | | | } |
| 232 | | | if (c != EOF && c != '\n') { |
| 233 | | | |
| 234 | | | while ((c = getc(ff)) != EOF && c != '\n') |
| 235 | | | ; |
| 236 | | | } |
| 237 | | | |
| 238 | | | if (c == EOF) { |
| 239 | | | if (ferror(ff)) |
| 240 | | | goto error; |
| 241 | | | else { |
| 242 | | | |
| 243 | | | g_warning("'%s' line %d doesn't have a newline.", ff_path,
x /usr/include/glib-2.0/glib/gmessages.h |
| |
153 | #define g_warning(...) g_log (G_LOG_DOMAIN, \ |
154 | G_LOG_LEVEL_WARNING, \ |
155 | __VA_ARGS__) |
| |
|
| 244 | | | line); |
| 245 | | | } |
| 246 | | | break; |
| 247 | | | } |
| 248 | | | |
| 249 | | | |
| 250 | | | if (prot_name_index >= prot_name_len) { |
| 251 | | | |
| 252 | | | prot_name_len *= 2; |
| 253 | | | prot_name = g_realloc(prot_name, prot_name_len + 1); |
| 254 | | | } |
| 255 | | | prot_name[prot_name_index] = '\0'; |
| 256 | | | |
| 257 | | | |
| 258 | | | prot = (protocol_def *) g_malloc(sizeof(protocol_def)); |
| 259 | | | prot->name = g_strdup(prot_name); |
| 260 | | | *flp = g_list_append(*flp, prot); |
| 261 | | | } |
| 262 | | | g_free(prot_name); |
| 263 | | | return 0; |
| 264 | | | |
| 265 | | | error: |
| 266 | | | return errno; |
| 267 | | | } |
| |