util: Expose function nullable_string_is_equal.
authorIlya Maximets <i.maximets@samsung.com>
Fri, 15 Jul 2016 11:54:53 +0000 (14:54 +0300)
committerDaniele Di Proietto <diproiettod@vmware.com>
Tue, 26 Jul 2016 01:39:29 +0000 (18:39 -0700)
Implementation of 'nullable_string_is_equal()' moved to util.c and
reused inside dpif-netdev.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
lib/dpif-netdev.c
lib/util.c
lib/util.h
ofproto/ofproto-dpif-ipfix.c
ofproto/ofproto-dpif-sflow.c

index d5d7b7e..f05ca4e 100644 (file)
@@ -2514,16 +2514,6 @@ dpif_netdev_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops)
     }
 }
 
-static bool
-cmask_equals(const char *a, const char *b)
-{
-    if (a && b) {
-        return !strcmp(a, b);
-    }
-
-    return a == NULL && b == NULL;
-}
-
 /* Changes the number or the affinity of pmd threads.  The changes are actually
  * applied in dpif_netdev_run(). */
 static int
@@ -2531,7 +2521,7 @@ dpif_netdev_pmd_set(struct dpif *dpif, const char *cmask)
 {
     struct dp_netdev *dp = get_dp_netdev(dpif);
 
-    if (!cmask_equals(dp->requested_pmd_cmask, cmask)) {
+    if (!nullable_string_is_equal(dp->requested_pmd_cmask, cmask)) {
         free(dp->requested_pmd_cmask);
         dp->requested_pmd_cmask = nullable_xstrdup(cmask);
     }
@@ -2741,7 +2731,7 @@ dpif_netdev_run(struct dpif *dpif)
 
     dp_netdev_pmd_unref(non_pmd);
 
-    if (!cmask_equals(dp->pmd_cmask, dp->requested_pmd_cmask)
+    if (!nullable_string_is_equal(dp->pmd_cmask, dp->requested_pmd_cmask)
         || ports_require_restart(dp)) {
         reconfigure_pmd_threads(dp);
     }
index e1dc3d2..241a7f1 100644 (file)
@@ -157,6 +157,12 @@ nullable_xstrdup(const char *s)
     return s ? xstrdup(s) : NULL;
 }
 
+bool
+nullable_string_is_equal(const char *a, const char *b)
+{
+    return a ? b && !strcmp(a, b) : !b;
+}
+
 char *
 xvasprintf(const char *format, va_list args)
 {
index 5049d15..3f6b690 100644 (file)
@@ -114,6 +114,7 @@ void *xmemdup(const void *, size_t) MALLOC_LIKE;
 char *xmemdup0(const char *, size_t) MALLOC_LIKE;
 char *xstrdup(const char *) MALLOC_LIKE;
 char *nullable_xstrdup(const char *) MALLOC_LIKE;
+bool nullable_string_is_equal(const char *a, const char *b);
 char *xasprintf(const char *format, ...) OVS_PRINTF_FORMAT(1, 2) MALLOC_LIKE;
 char *xvasprintf(const char *format, va_list) OVS_PRINTF_FORMAT(1, 0) MALLOC_LIKE;
 void *x2nrealloc(void *p, size_t *n, size_t s);
index 0128c91..abea492 100644 (file)
@@ -463,12 +463,6 @@ static void get_export_time_now(uint64_t *, uint32_t *);
 
 static void dpif_ipfix_cache_expire_now(struct dpif_ipfix_exporter *, bool);
 
-static bool
-nullable_string_is_equal(const char *a, const char *b)
-{
-    return a ? b && !strcmp(a, b) : !b;
-}
-
 static bool
 ofproto_ipfix_bridge_exporter_options_equal(
     const struct ofproto_ipfix_bridge_exporter_options *a,
index 8a19d15..1252d39 100644 (file)
@@ -91,12 +91,6 @@ static void dpif_sflow_del_port__(struct dpif_sflow *,
 
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
 
-static bool
-nullable_string_is_equal(const char *a, const char *b)
-{
-    return a ? b && !strcmp(a, b) : !b;
-}
-
 static bool
 ofproto_sflow_options_equal(const struct ofproto_sflow_options *a,
                          const struct ofproto_sflow_options *b)