[ovs-dev] [memory fixes 3/6] vswitchd: Fix dependency on DP_MAX_PORTS for allocating "struct dst"s.

Ben Pfaff blp at nicira.com
Mon Dec 13 22:29:39 UTC 2010


On Mon, Dec 13, 2010 at 01:43:56PM -0800, Justin Pettit wrote:
> On Dec 13, 2010, at 1:10 PM, Ben Pfaff wrote:
> 
> > +static void
> > +dst_set_add(struct dst_set *set, const struct dst *dst)
> > +{
> > +    if (set->n >= set->allocated) {
> > +        size_t new_allocated;
> > +        struct dst *new_dsts;
> > +
> > +        new_allocated = set->allocated * 2;
> > +        new_dsts = xmalloc(new_allocated * sizeof *new_dsts);
> > +        memcpy(new_dsts, set->dsts, set->n * sizeof *new_dsts);
> > +
> > +        free(set->dsts);
> 
> Initially, this points to "set->builtin", so I don't think this is safe.

Oops.  Fixed, thanks.

> > @@ -2428,19 +2473,20 @@ compose_actions(struct bridge *br, const struct flow *flow, uint16_t vlan,
> >                 tag_type *tags, struct ofpbuf *actions,
> >                 uint16_t *nf_output_iface)
> > {
> > ...
> > -    for (p = dsts; p < &dsts[n_dsts]; p++) {
> > +    for (i = 0; i < set.n; i++) {
> > +        const struct dst *p = &set.dsts[i];
> 
> This is very minor, but elsewhere in the patch, you switched from
> using "p" to "dst".

Might as well do that here too, since it's a better name.

Thanks,

Ben.




More information about the dev mailing list