ovsdb: add ovsdb_monitor_row_update_type()
authorAndy Zhou <azhou@nicira.com>
Wed, 10 Jun 2015 20:19:43 +0000 (13:19 -0700)
committerAndy Zhou <azhou@nicira.com>
Wed, 24 Jun 2015 00:05:20 +0000 (17:05 -0700)
The logic of determining row update type will be useful in the following
patch. Make it into a function.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovsdb/monitor.c

index 257959c..ddfb6f1 100644 (file)
@@ -458,6 +458,15 @@ ovsdb_monitor_changes_destroy(struct ovsdb_monitor_changes *changes)
     free(changes);
 }
 
+static enum ovsdb_monitor_selection
+ovsdb_monitor_row_update_type(bool initial, const bool old, const bool new)
+{
+    return initial ? OJMS_INITIAL
+            : !old ? OJMS_INSERT
+            : !new ? OJMS_DELETE
+            : OJMS_MODIFY;
+}
+
 /* Returns JSON for a <row-update> (as described in RFC 7047) for 'row' within
  * 'mt', or NULL if no row update should be sent.
  *
@@ -478,10 +487,7 @@ ovsdb_monitor_compose_row_update(
     struct json *row_json;
     size_t i;
 
-    type = (initial ? OJMS_INITIAL
-            : !row->old ? OJMS_INSERT
-            : !row->new ? OJMS_DELETE
-            : OJMS_MODIFY);
+    type = ovsdb_monitor_row_update_type(initial, row->old, row->new);
     if (!(mt->select & type)) {
         return NULL;
     }