[ovs-dev] [meters 4/9] ofproto: Change 'const uint32_t *meter_id' to just 'uint32_t meter_id'.

Ben Pfaff blp at nicira.com
Thu Jun 27 22:19:39 UTC 2013


I see no point in passing a uint32_t by const pointer.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 ofproto/ofproto.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index bea6df1..6d87972 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -198,15 +198,14 @@ static bool rule_is_modifiable(const struct rule *);
 /* OpenFlow. */
 static enum ofperr add_flow(struct ofproto *, struct ofconn *,
                             const struct ofputil_flow_mod *,
-                            const struct ofp_header *,
-                            const uint32_t *meter_id);
+                            const struct ofp_header *, uint32_t meter_id);
 static void delete_flow__(struct rule *, struct ofopgroup *,
                           enum ofp_flow_removed_reason);
 static bool handle_openflow(struct ofconn *, const struct ofpbuf *);
 static enum ofperr handle_flow_mod__(struct ofproto *, struct ofconn *,
                                      const struct ofputil_flow_mod *,
                                      const struct ofp_header *,
-                                     const uint32_t *meter_id);
+                                     uint32_t meter_id);
 static void calc_duration(long long int start, long long int now,
                           uint32_t *sec, uint32_t *nsec);
 
@@ -1614,7 +1613,6 @@ ofproto_add_flow(struct ofproto *ofproto, const struct match *match,
     if (!rule || !ofpacts_equal(rule->ofpacts, rule->ofpacts_len,
                                 ofpacts, ofpacts_len)) {
         struct ofputil_flow_mod fm;
-        uint32_t meter_id = 0;
 
         memset(&fm, 0, sizeof fm);
         fm.match = *match;
@@ -1622,7 +1620,7 @@ ofproto_add_flow(struct ofproto *ofproto, const struct match *match,
         fm.buffer_id = UINT32_MAX;
         fm.ofpacts = xmemdup(ofpacts, ofpacts_len);
         fm.ofpacts_len = ofpacts_len;
-        add_flow(ofproto, NULL, &fm, NULL, &meter_id);
+        add_flow(ofproto, NULL, &fm, NULL, 0);
         free(fm.ofpacts);
     }
 }
@@ -1637,8 +1635,7 @@ ofproto_add_flow(struct ofproto *ofproto, const struct match *match,
 int
 ofproto_flow_mod(struct ofproto *ofproto, const struct ofputil_flow_mod *fm)
 {
-    uint32_t meter_id = 0;
-    return handle_flow_mod__(ofproto, NULL, fm, NULL, &meter_id);
+    return handle_flow_mod__(ofproto, NULL, fm, NULL, 0);
 }
 
 /* Searches for a rule with matching criteria exactly equal to 'target' in
@@ -3284,7 +3281,7 @@ is_flow_deletion_pending(const struct ofproto *ofproto,
 static enum ofperr
 add_flow(struct ofproto *ofproto, struct ofconn *ofconn,
          const struct ofputil_flow_mod *fm, const struct ofp_header *request,
-         const uint32_t *meter_id)
+         uint32_t meter_id)
 {
     struct oftable *table;
     struct ofopgroup *group;
@@ -3361,7 +3358,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn,
        and OFPFF13_NO_BYT_COUNTS */
     rule->ofpacts = xmemdup(fm->ofpacts, fm->ofpacts_len);
     rule->ofpacts_len = fm->ofpacts_len;
-    rule->meter_id = *meter_id;
+    rule->meter_id = meter_id;
     list_init(&rule->meter_list_node);
     rule->evictable = true;
     rule->eviction_group = NULL;
@@ -3435,7 +3432,7 @@ static enum ofperr
 modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn,
                const struct ofputil_flow_mod *fm,
                const struct ofp_header *request,
-               const uint32_t *meter_id, struct list *rules)
+               uint32_t meter_id, struct list *rules)
 {
     struct ofopgroup *group;
     struct rule *rule;
@@ -3470,7 +3467,7 @@ modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn,
             op->meter_id = rule->meter_id;
             rule->ofpacts = xmemdup(fm->ofpacts, fm->ofpacts_len);
             rule->ofpacts_len = fm->ofpacts_len;
-            rule->meter_id = *meter_id;
+            rule->meter_id = meter_id;
             rule->ofproto->ofproto_class->rule_modify_actions(rule);
         } else {
             ofoperation_complete(op, 0);
@@ -3485,7 +3482,7 @@ static enum ofperr
 modify_flows_add(struct ofproto *ofproto, struct ofconn *ofconn,
                  const struct ofputil_flow_mod *fm,
                  const struct ofp_header *request,
-                 const uint32_t *meter_id)
+                 uint32_t meter_id)
 {
     if (fm->cookie_mask != htonll(0) || fm->new_cookie == htonll(UINT64_MAX)) {
         return 0;
@@ -3502,7 +3499,7 @@ static enum ofperr
 modify_flows_loose(struct ofproto *ofproto, struct ofconn *ofconn,
                    const struct ofputil_flow_mod *fm,
                    const struct ofp_header *request,
-                   const uint32_t *meter_id)
+                   uint32_t meter_id)
 {
     struct list rules;
     int error;
@@ -3527,8 +3524,7 @@ modify_flows_loose(struct ofproto *ofproto, struct ofconn *ofconn,
 static enum ofperr
 modify_flow_strict(struct ofproto *ofproto, struct ofconn *ofconn,
                    const struct ofputil_flow_mod *fm,
-                   const struct ofp_header *request,
-                   const uint32_t *meter_id)
+                   const struct ofp_header *request, uint32_t meter_id)
 {
     struct list rules;
     int error;
@@ -3710,7 +3706,7 @@ handle_flow_mod(struct ofconn *ofconn, const struct ofp_header *oh)
     }
 
     if (!error) {
-        error = handle_flow_mod__(ofproto, ofconn, &fm, oh, &meter_id);
+        error = handle_flow_mod__(ofproto, ofconn, &fm, oh, meter_id);
     }
     if (error) {
         goto exit_free_ofpacts;
@@ -3751,8 +3747,7 @@ exit:
 static enum ofperr
 handle_flow_mod__(struct ofproto *ofproto, struct ofconn *ofconn,
                   const struct ofputil_flow_mod *fm,
-                  const struct ofp_header *oh,
-                  const uint32_t *meter_id)
+                  const struct ofp_header *oh, uint32_t meter_id)
 {
     if (ofproto->n_pending >= 50) {
         ovs_assert(!list_is_empty(&ofproto->pending));
-- 
1.7.2.5




More information about the dev mailing list