On Thu, Jun 27, 2013 at 5:10 PM, Ben Pfaff <b...@nicira.com> wrote:
>
> -    while (!ds_get_preprocessed_line(&s, stream)) {
> +    line_number = 0;
> +    while (!ds_get_preprocessed_line(&s, stream, &line_number)) {
> +        char *error;
> +
>          if (*n_fms >= allocated_fms) {
>              *fms = x2nrealloc(*fms, &allocated_fms, sizeof **fms);
>          }
> -        parse_ofp_flow_mod_str(&(*fms)[*n_fms], ds_cstr(&s), command,
> false);
> +        error = parse_ofp_flow_mod_str(&(*fms)[*n_fms], ds_cstr(&s),
> command);
> +        if (error) {
> +            size_t i;
> +
> +            for (i = 0; i < *n_fms; i++) {
> +                free((*fms)[i].ofpacts);
> +            }
> +            free(*fms);
> +            *fms = NULL;
> +            *n_fms = 0;
> +
> +            return xasprintf("%s:%d: %s", file_name, line_number, error);
> +        }
>          *n_fms += 1;
>      }
>      ds_destroy(&s);
> @@ -1340,21 +1688,28 @@ parse_ofp_flow_mod_file(const char *file_name,
> uint16_t command,
>      if (stream != stdin) {
>          fclose(stream);
>      }
> +    return NULL;
>  }
>


One more point, should also close the stream before return.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to