struct svec new_cfg;
struct svec old_br;
struct svec old_keys;
- char buf[1024];
size_t i, j;
int n_ports = -1;
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);
* 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);