ovsdb-idlc: Constify 'char **'.
authorRussell Bryant <rbryant@redhat.com>
Thu, 19 Feb 2015 18:10:51 +0000 (13:10 -0500)
committerBen Pfaff <blp@nicira.com>
Thu, 19 Feb 2015 18:12:19 +0000 (10:12 -0800)
Update the logic used in constify() to add const to a 'char **' while
still excluding all other cases of more than one level of indirection.

This results in adding const to a parameter of a generated setter
function where we're generally passing in array of constant strings.
As a result, this patch includes the other necessary fixes to the code
base to reflect the const addition.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovsdb/ovsdb-idlc.in
vswitchd/bridge.c

index 6c8aa43..67e8a4e 100755 (executable)
@@ -21,7 +21,9 @@ def annotateSchema(schemaFile, annotationFile):
     sys.stdout.write('\n')
 
 def constify(cType, const):
-    if (const and cType.endswith('*') and not cType.endswith('**')):
+    if (const
+        and cType.endswith('*') and
+        (cType == 'char **' or not cType.endswith('**'))):
         return 'const %s' % cType
     else:
         return cType
index 297c0dd..7d9cf25 100644 (file)
@@ -2262,7 +2262,7 @@ iface_refresh_cfm_stats(struct iface *iface)
                 reasons[j++] = cfm_fault_reason_to_str(reason);
             }
         }
-        ovsrec_interface_set_cfm_fault_status(cfg, (char **) reasons, j);
+        ovsrec_interface_set_cfm_fault_status(cfg, reasons, j);
 
         ovsrec_interface_set_cfm_flap_count(cfg, &cfm_flap_count, 1);
 
@@ -2307,7 +2307,7 @@ iface_refresh_stats(struct iface *iface)
     enum { N_IFACE_STATS = IFACE_STATS };
 #undef IFACE_STAT
     int64_t values[N_IFACE_STATS];
-    char *keys[N_IFACE_STATS];
+    const char *keys[N_IFACE_STATS];
     int n;
 
     struct netdev_stats stats;
@@ -2419,7 +2419,7 @@ port_refresh_stp_stats(struct port *port)
     struct ofproto *ofproto = port->bridge->ofproto;
     struct iface *iface;
     struct ofproto_port_stp_stats stats;
-    char *keys[3];
+    const char *keys[3];
     int64_t int_values[3];
 
     if (port_is_synthetic(port)) {
@@ -2489,7 +2489,7 @@ port_refresh_rstp_status(struct port *port)
     struct ofproto *ofproto = port->bridge->ofproto;
     struct iface *iface;
     struct ofproto_port_rstp_status status;
-    char *keys[3];
+    const char *keys[3];
     int64_t int_values[3];
     struct smap smap;
 
@@ -4728,7 +4728,7 @@ mirror_refresh_stats(struct mirror *m)
 {
     struct ofproto *ofproto = m->bridge->ofproto;
     uint64_t tx_packets, tx_bytes;
-    char *keys[2];
+    const char *keys[2];
     int64_t values[2];
     size_t stat_cnt = 0;