[ovs-dev] [PATCH] vswitchd: Avoid writing to const struct
Ed Maste
emaste at freebsd.org
Fri Dec 7 22:41:16 UTC 2012
When built with Clang, vswitchd segfaulted in ovsrec_open_vswitch_init,
from calling memset() on a const struct.
Signed-off-by: Ed Maste <emaste at freebsd.org>
---
This could be addressed instead by just dropping the const in the
null_cfg definition, if preferred.
vswitchd/bridge.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index b1d2feb..f9d6f69 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2105,7 +2105,8 @@ bridge_run_fast(void)
void
bridge_run(void)
{
- static const struct ovsrec_open_vswitch null_cfg;
+ static struct ovsrec_open_vswitch _null_cfg;
+ const struct ovsrec_open_vswitch *null_cfg = &_null_cfg;
const struct ovsrec_open_vswitch *cfg;
struct ovsdb_idl_txn *reconf_txn = NULL;
struct sset types;
@@ -2114,7 +2115,7 @@ bridge_run(void)
bool vlan_splinters_changed;
struct bridge *br;
- ovsrec_open_vswitch_init((struct ovsrec_open_vswitch *) &null_cfg);
+ ovsrec_open_vswitch_init(&_null_cfg);
/* (Re)configure if necessary. */
if (!reconfiguring) {
@@ -2190,7 +2191,7 @@ bridge_run(void)
} else {
/* We still need to reconfigure to avoid dangling pointers to
* now-destroyed ovsrec structures inside bridge data. */
- bridge_reconfigure(&null_cfg);
+ bridge_reconfigure(null_cfg);
}
}
}
@@ -2204,7 +2205,7 @@ bridge_run(void)
ovsrec_open_vswitch_set_cur_cfg(cfg, cfg->next_cfg);
}
} else {
- bridge_reconfigure_continue(&null_cfg);
+ bridge_reconfigure_continue(null_cfg);
}
}
--
1.7.11.5
More information about the dev
mailing list