mirror of
https://github.com/openvswitch/ovs
synced 2025-09-05 08:45:23 +00:00
cmap, classifier: Avoid unsafe aliasing in iterators.
CMAP_FOR_EACH and CLS_FOR_EACH and their variants tried to use void ** as a "pointer to any kind of pointer". That is a violation of the aliasing rules in ISO C which technically yields undefined behavior. With GCC 4.1, it causes both warnings and actual misbehavior. One option would to add -fno-strict-aliasing to the compiler flags, but that would only help with GCC; who knows whether this can be worked around with other compilers. Instead, this commit rewrites the iterators to avoid disallowed pointer aliasing. VMware-BZ: #1287651 Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
This commit is contained in:
@@ -962,10 +962,10 @@ dp_netdev_remove_flow(struct dp_netdev *dp, struct dp_netdev_flow *flow)
|
||||
static void
|
||||
dp_netdev_flow_flush(struct dp_netdev *dp)
|
||||
{
|
||||
struct dp_netdev_flow *netdev_flow, *next;
|
||||
struct dp_netdev_flow *netdev_flow;
|
||||
|
||||
ovs_mutex_lock(&dp->flow_mutex);
|
||||
CMAP_FOR_EACH_SAFE (netdev_flow, next, node, &dp->flow_table) {
|
||||
CMAP_FOR_EACH_SAFE (netdev_flow, node, &dp->flow_table) {
|
||||
dp_netdev_remove_flow(dp, netdev_flow);
|
||||
}
|
||||
ovs_mutex_unlock(&dp->flow_mutex);
|
||||
|
Reference in New Issue
Block a user