The logic of determining row update type will be useful in the following patch. Make it into a function.
Signed-off-by: Andy Zhou <az...@nicira.com> --- ovsdb/monitor.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c index 257959c..107bdef 100644 --- a/ovsdb/monitor.c +++ b/ovsdb/monitor.c @@ -458,6 +458,21 @@ ovsdb_monitor_changes_destroy(struct ovsdb_monitor_changes *changes) free(changes); } +/* + * Return the monitor selection type. + * + * The type is determined not based on the contents of 'old' and 'new', + * but rather based on whether the pointer is NULL or not. Thus their + * type is not important and can be left generic. */ +static enum ovsdb_monitor_selection +ovsdb_monitor_row_update_type(bool initial, const void *old, const void *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 +493,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; } -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev