brcompat: Remove line-length limitations from brc_modify_config().
authorBen Pfaff <blp@nicira.com>
Tue, 30 Dec 2008 21:40:10 +0000 (13:40 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 30 Dec 2008 21:40:10 +0000 (13:40 -0800)
vswitchd/brcompat.c

index 5c432da4b6e139787277c5210fe4a976a30763e3..9fe89720cb752bdeb9ce77ffaaffdd94d9f651d9 100644 (file)
@@ -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);