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 <rbry...@redhat.com>
---
 ovsdb/ovsdb-idlc.in |  4 +++-
 vswitchd/bridge.c   | 10 +++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 6c8aa43..67e8a4e 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -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
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 297c0dd..7d9cf25 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -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;
 
-- 
2.1.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to