From: Ben Pfaff Date: Tue, 30 Dec 2008 21:40:10 +0000 (-0800) Subject: brcompat: Remove line-length limitations from brc_modify_config(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52e60d4e31391e9496f0d7f4cd478b674ff53876;p=openvswitch brcompat: Remove line-length limitations from brc_modify_config(). --- diff --git a/vswitchd/brcompat.c b/vswitchd/brcompat.c index 5c432da4..9fe89720 100644 --- a/vswitchd/brcompat.c +++ b/vswitchd/brcompat.c @@ -218,7 +218,6 @@ brc_modify_config(const char *dp_name, const char *port_name, struct svec new_cfg; struct svec old_br; struct svec old_keys; - char buf[1024]; size_t i, j; int n_ports = -1; @@ -240,19 +239,16 @@ brc_modify_config(const char *dp_name, const char *port_name, n_ports = old_keys.n - 1; continue; } - if (snprintf(buf, sizeof(buf), "bridge.%s.port = %s\n", - old_br.names[i], old_keys.names[j]) >= sizeof(buf)) { - VLOG_WARN_RL(&rl, "config line too long, skipping"); - continue; - } - svec_add(&new_cfg, buf); + svec_add_nocopy(&new_cfg, + xasprintf("bridge.%s.port = %s\n", + old_br.names[i], old_keys.names[j])); } cfg_get_all_keys(&old_keys, "bridge.%s.enabled", old_br.names[i]); for (j = 0; j < old_keys.n; j++) { - snprintf(buf, sizeof(buf), "bridge.%s.enabled = true\n", - old_br.names[i]); - svec_add(&new_cfg, buf); + svec_add_nocopy(&new_cfg, + xasprintf("bridge.%s.enabled = true\n", + old_br.names[i])); } } svec_destroy(&old_br); @@ -262,13 +258,13 @@ brc_modify_config(const char *dp_name, const char *port_name, * this dummy entry so that it's still created when vswitchd is * restarted. */ if ((act == BMC_ADD_DP) || (n_ports == 0)) { - snprintf(buf, sizeof(buf), "bridge.%s.enabled = true\n", dp_name); - svec_add(&new_cfg, buf); + svec_add_nocopy(&new_cfg, + xasprintf("bridge.%s.enabled = true\n", dp_name)); } if (act == BMC_ADD_PORT) { - snprintf(buf, sizeof(buf), "bridge.%s.port = %s\n", dp_name, port_name); - svec_add(&new_cfg, buf); + svec_add_nocopy(&new_cfg, xasprintf("bridge.%s.port = %s\n", + dp_name, port_name)); } brc_write_config(&new_cfg);