[ovs-dev] [PATCH v2 1/5] classifier: Constify RCU pointers.

Ben Pfaff blp at nicira.com
Thu Nov 6 19:06:59 UTC 2014


On Thu, Nov 06, 2014 at 11:02:56AM -0800, Ben Pfaff wrote:
> On Mon, Nov 03, 2014 at 11:39:00AM -0800, Jarno Rajahalme wrote:
> > Returning const struct cls_rule pointers from the classifier API helps
> > callers to remember that they should not modify the rules returned.
> > 
> > Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> 
> I don't think it has much practical effect since most of the callers
> immediately cast the pointer to some other container type, but it does
> seem a little nicer.
> 
> Acked-by: Ben Pfaff <blp at nicira.com>

But you'll need to fix up ovs-router.c, which I think is new since you
posted this.  It has some build failures (GCC and sparse output
interleaved below):

../lib/ovs-router.c:142:8: warning: incorrect type in assignment (different modifiers)
../lib/ovs-router.c:142:8:    expected struct cls_rule *cr
../lib/ovs-router.c:142:8:    got struct cls_rule const *
../lib/ovs-router.c:145:12: warning: incorrect type in assignment (different modifiers)
../lib/ovs-router.c:145:12:    expected struct cls_rule *cr
../lib/ovs-router.c:145:12:    got struct cls_rule const *
../lib/ovs-router.c: In function 'rt_entry_delete':
../lib/ovs-router.c:142:8: error: assignment discards 'const' qualifier from pointer target type [-Werror]
     cr = classifier_find_rule_exactly(&cls, &rule);
        ^
../lib/ovs-router.c:145:12: error: assignment discards 'const' qualifier from pointer target type [-Werror]
         cr = classifier_remove(&cls, cr);
            ^



More information about the dev mailing list