Thanks Ryan for quick turn around. It is good to take care those little things while it is fresh in our minds. I will push it in a minute.
On Wed, May 21, 2014 at 9:56 PM, Ryan Wilson 76511 <wr...@vmware.com> wrote: > Thanks for this, Andy! > > Acked-by: Ryan Wilson <wr...@nicira.com> > ________________________________________ > From: dev <dev-boun...@openvswitch.org> on behalf of Andy Zhou > <az...@nicira.com> > Sent: Wednesday, May 21, 2014 9:47 PM > To: d...@openvswitch.com > Subject: [ovs-dev] [PATCH] ofproto: Add const to immutable members of > ofgroup. > > Signed-off-by: Andy Zhou <az...@nicira.com> > --- > ofproto/ofproto-provider.h | 12 ++++++------ > ofproto/ofproto.c | 21 ++++++++++++--------- > 2 files changed, 18 insertions(+), 15 deletions(-) > > diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h > index e5f71c7..9f87ba9 100644 > --- a/ofproto/ofproto-provider.h > +++ b/ofproto/ofproto-provider.h > @@ -489,15 +489,15 @@ struct ofgroup { > > /* No lock is needed to protect the fields below since they are not > * modified after construction. */ > - struct ofproto *ofproto; /* The ofproto that contains this group. */ > - uint32_t group_id; > - enum ofp11_group_type type; /* One of OFPGT_*. */ > + const struct ofproto *ofproto; /* The ofproto that contains this group. > */ > + const uint32_t group_id; > + const enum ofp11_group_type type; /* One of OFPGT_*. */ > > - long long int created; /* Creation time. */ > - long long int modified; /* Time of last modification. */ > + const long long int created; /* Creation time. */ > + const long long int modified; /* Time of last modification. */ > > struct list buckets; /* Contains "struct ofputil_bucket"s. */ > - uint32_t n_buckets; > + const uint32_t n_buckets; > }; > > bool ofproto_group_lookup(const struct ofproto *ofproto, uint32_t group_id, > diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c > index 7fd4ac1..7952984 100644 > --- a/ofproto/ofproto.c > +++ b/ofproto/ofproto.c > @@ -5420,7 +5420,7 @@ static uint32_t > group_get_ref_count(struct ofgroup *group) > OVS_EXCLUDED(ofproto_mutex) > { > - struct ofproto *ofproto = group->ofproto; > + struct ofproto *ofproto = CONST_CAST(struct ofproto *, group->ofproto); > struct rule_criteria criteria; > struct rule_collection rules; > struct match match; > @@ -5445,7 +5445,7 @@ static void > append_group_stats(struct ofgroup *group, struct list *replies) > { > struct ofputil_group_stats ogs; > - struct ofproto *ofproto = group->ofproto; > + const struct ofproto *ofproto = group->ofproto; > long long int now = time_msec(); > int error; > > @@ -5597,6 +5597,7 @@ init_group(struct ofproto *ofproto, struct > ofputil_group_mod *gm, > struct ofgroup **ofgroup) > { > enum ofperr error; > + const long long int now = time_msec(); > > if (gm->group_id > OFPG_MAX) { > return OFPERR_OFPGMFC_INVALID_GROUP; > @@ -5611,14 +5612,16 @@ init_group(struct ofproto *ofproto, struct > ofputil_group_mod *gm, > return OFPERR_OFPGMFC_OUT_OF_GROUPS; > } > > - (*ofgroup)->ofproto = ofproto; > - (*ofgroup)->group_id = gm->group_id; > - (*ofgroup)->type = gm->type; > - (*ofgroup)->created = (*ofgroup)->modified = time_msec(); > + (*ofgroup)->ofproto = ofproto; > + *CONST_CAST(uint32_t *, &((*ofgroup)->group_id)) = gm->group_id; > + *CONST_CAST(enum ofp11_group_type *, &(*ofgroup)->type) = gm->type; > + *CONST_CAST(long long int *, &((*ofgroup)->created)) = now; > + *CONST_CAST(long long int *, &((*ofgroup)->modified)) = now; > ovs_refcount_init(&(*ofgroup)->ref_count); > > list_move(&(*ofgroup)->buckets, &gm->buckets); > - (*ofgroup)->n_buckets = list_size(&(*ofgroup)->buckets); > + *CONST_CAST(uint32_t *, &(*ofgroup)->n_buckets) = > + list_size(&(*ofgroup)->buckets); > > /* Construct called BEFORE any locks are held. */ > error = ofproto->ofproto_class->group_construct(*ofgroup); > @@ -5722,8 +5725,8 @@ modify_group(struct ofproto *ofproto, struct > ofputil_group_mod *gm) > } > > /* The group creation time does not change during modification. */ > - new_ofgroup->created = ofgroup->created; > - new_ofgroup->modified = time_msec(); > + *CONST_CAST(long long int *, &(new_ofgroup->created)) = ofgroup->created; > + *CONST_CAST(long long int *, &(new_ofgroup->modified)) = time_msec(); > > error = ofproto->ofproto_class->group_modify(new_ofgroup); > if (error) { > -- > 1.9.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=TfBS78Vw3dzttvXidhbffg%3D%3D%0A&m=pm3O8fVsg71T%2FXIZoLca6BG0pt29abFhUdGZf%2BR2ewM%3D%0A&s=c538f3b1421a435dd9ac958f0b154c041429041217db3dd699a82f337208005d _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev