[ovs-dev] [PATCH] ofp-parse: Do not exit() upon a parse error.
Ben Pfaff
blp at nicira.com
Mon Jul 8 17:15:10 UTC 2013
On Tue, Jul 02, 2013 at 05:53:20PM -0700, Alex Wang wrote:
> On Thu, Jun 27, 2013 at 5:10 PM, Ben Pfaff <blp at 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.
Thanks, I've fixed that now too.
More information about the dev
mailing list