[ovs-dev] [PATCH v2 ovn] logical-fields: fix memory leak while initializing ovnfield_by_name

Damijan Skvarc damjan.skvarc at gmail.com
Fri Aug 9 07:11:47 UTC 2019


According to comments I have:
- renamed function name to be "paired" with ovn_destroy_ovnfields
- replaced 0/1 bool values with false/true

Signed-off-by: Damijan Skvarc <damjan.skvarc at gmail.com>
---
 lib/logical-fields.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/logical-fields.c b/lib/logical-fields.c
index fdc78cf..8a0ef62 100644
--- a/lib/logical-fields.c
+++ b/lib/logical-fields.c
@@ -58,18 +58,18 @@ add_ct_bit(const char *name, int index, struct shash *symtab)
 }
 
 static void
-init_ovnfield_by_name(void)
+ovn_init_ovnfields(void)
 {
-    static bool initialized = 0;
+    static bool initialized = false;
 
-    if (0 == initialized) {
+    if (!initialized) {
         shash_init(&ovnfield_by_name);
         for (int i = 0; i < OVN_FIELD_N_IDS; i++) {
             const struct ovn_field *of = &ovn_fields[i];
             ovs_assert(of->id == i); /* Fields must be in the enum order. */
             shash_add_once(&ovnfield_by_name, of->name, of);
         }
-        initialized = 1;
+        initialized = true;
     }
 }
 
@@ -234,7 +234,7 @@ ovn_init_symtab(struct shash *symtab)
     expr_symtab_add_field(symtab, "sctp.src", MFF_SCTP_SRC, "sctp", false);
     expr_symtab_add_field(symtab, "sctp.dst", MFF_SCTP_DST, "sctp", false);
 
-    init_ovnfield_by_name();
+    ovn_init_ovnfields();
 
     expr_symtab_add_ovn_field(symtab, "icmp4.frag_mtu", OVN_ICMP4_FRAG_MTU);
 }
-- 
2.7.4



More information about the dev mailing list