ovn-controller: Introduce helpers for looking up datapaths.
authorBen Pfaff <blp@ovn.org>
Tue, 12 Apr 2016 01:48:38 +0000 (18:48 -0700)
committerBen Pfaff <blp@ovn.org>
Tue, 12 Apr 2016 17:33:32 +0000 (10:33 -0700)
commite4426e3457bb23efb1421a6e033f5ef605de19cd
treea3b9418463f053099dae82529496a84d311b3b72
parenta9360f2ab9d41ba2e4202e0bdc4d0a2754a3244d
ovn-controller: Introduce helpers for looking up datapaths.

The new helpers get_local_datapath() and get_patched_datapath() make code
a little shorter and easier to read.  They also avoid a pitfall that was
present in at least a few of the instances: CONTAINER_OF is not safe on a
null pointer, because it does a raw pointer subtraction and will change
NULL to something else.  This wasn't actually a problem in these particular
cases because the value it was subtracting was zero (although arguably it
is still undefined behavior because the compiler is allowed to assume that
a pointer on which arithmetic is performed is nonnull).

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
ovn/controller/binding.c
ovn/controller/lflow.c
ovn/controller/ovn-controller.c
ovn/controller/ovn-controller.h
ovn/controller/patch.c
ovn/controller/physical.c